本文整理汇总了Java中com.jagrosh.jdautilities.commandclient.CommandEvent.isFromType方法的典型用法代码示例。如果您正苦于以下问题:Java CommandEvent.isFromType方法的具体用法?Java CommandEvent.isFromType怎么用?Java CommandEvent.isFromType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jagrosh.jdautilities.commandclient.CommandEvent
的用法示例。
在下文中一共展示了CommandEvent.isFromType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
int res = Constant.music.connectToVoiceChat(event.getGuild().getAudioManager(), event.getMember());
if (res == 0) {
event.replyWarning(event.getMember().getAsMention() + " Please connect in a voice channel first");
} else {
event.replySuccess("Connected");
}
}
示例2: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (event.getGuild().getAudioManager().isConnected()) {
if (!Constant.music.getGuildAudioPlayer(event.getGuild()).scheduler.getQueue().isEmpty()) {
Constant.music.getGuildAudioPlayer(event.getGuild()).scheduler.shuffleQueue();
event.reactSuccess();
}else{
event.reply("The queue is empty, there is nothing to shuffle");
}
}else{
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
}
示例3: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (event.getGuild().getAudioManager().isConnected()) {
if (Constant.music.getGuildAudioPlayer(event.getGuild()).player.getPlayingTrack() != null) {
Constant.nowPlayingList.get(event.getGuild().getId()).resendNowPlaying();
} else {
event.replyWarning("I'm not playing anything");
}
}else{
event.replyError(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
}
示例4: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
String id = null;
if (event.isFromType(ChannelType.TEXT)) {
id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (event.getGuild().getAudioManager().isConnected()) {
if (!event.getArgs().isEmpty()) {
Constant.music.loadAndPlay(event);
if (id != null) {
if (!Constant.nowPlayingList.containsKey(event.getGuild().getId())) {
new NowPlaying(event.getGuild(), Constant.music);
}
}
} else {
event.replyWarning(event.getMember().getAsMention() + " You need to specify an url");
}
} else {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
}
示例5: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (!event.getArgs().isEmpty()) {
if (event.getGuild().getAudioManager().isConnected()) {
String cc = "ytsearch:" + event.getArgs();
Constant.music.loadAndPlaySearch(event, waiter, cc);
} else {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
} else {
event.replyWarning(event.getMember().getAsMention() + " You need to specify an url");
}
}
示例6: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
int res = Constant.music.disconnectFromVoiceChat(event.getGuild().getAudioManager());
if (res == 0) {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
} else {
event.replySuccess("Disconnected");
}
}
示例7: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
Set<User> list;
EmbedBuilder builder = new EmbedBuilder();
Color color;
if(event.isFromType(ChannelType.PRIVATE))
{
color = Color.decode("#33ff00");
}
else
{
color = event.getGuild().getSelfMember().getColor();
}
try
{
list = db.getBlacklistedUsersList(event.getJDA());
if(list.isEmpty())
{
event.reply("The list is empty!");
}
else
{
builder.setDescription(list.stream().map(u -> u.getName()+"#"+u.getDiscriminator()+" (ID: "+u.getId()+")").collect(Collectors.joining("\n")));
builder.setFooter(event.getSelfUser().getName()+"'s Blacklisted Users", event.getSelfUser().getEffectiveAvatarUrl());
builder.setColor(color);
event.reply(builder.build());
}
}
catch(Exception e)
{
event.replyError("Something went wrong when getting the blacklisted users list: \n```"+e+"```");
}
}
示例8: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
try
{
Color color;
if (event.isFromType(ChannelType.PRIVATE))
color = Color.decode("#33ff00");
else
color = event.getMember().getColor();
EmbedBuilder builder = new EmbedBuilder();
OkHttpClient client = new OkHttpClient();
Request req = new Request.Builder().url("https://random.dog/woof.json").get().build();
Response res = client.newCall(req).execute();
if(!res.isSuccessful())
throw new RuntimeException("Error while fetching remote resource");
ResponseBody body = res.body();
String data = body.string();
JSONObject json = new JSONObject(data);
String cat = json.getString("url");
builder.setAuthor("Requested by "+event.getAuthor().getName(), null, event.getAuthor().getEffectiveAvatarUrl());
builder.setImage(cat);
builder.setFooter("Image provided by random.dog API", null);
builder.setColor(color);
event.reply(builder.build());
}
catch(IOException | RuntimeException e)
{
event.replyError("An error was thrown when getting the image! Ask the Owner to check the Console.");
LOG.error(e.getMessage());
if (config.isDebugEnabled())
e.printStackTrace();
}
}
示例9: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
protected void execute(CommandEvent event)
{
String args = event.getArgs();
if(config.getGihpyKey().isEmpty())
{
event.replyError("This command has been disabled due a faulty parameter on the config file, ask the Owner to check the Console");
LOG.warn("Someone triggered the Giphy command, but there isn't a key in the config file. In order to stop this message add a key to the config file.");
return;
}
if(args.isEmpty())
{
event.replyWarning("No search terms specified!");
return;
}
Color color;
if(event.isFromType(ChannelType.PRIVATE))
color = Color.decode("#33ff00");
else
color = event.getMember().getColor();
SimpleGiphy.setApiKey(config.getGihpyKey());
RandomGiphyResponse r;
EmbedBuilder builder = new EmbedBuilder();
String title = "<:giphy:373675520099090436> Random Giphy Image:";
r = SimpleGiphy.getInstance().random(args, "pg-13");
RandomGiphy gif = r.getRandomGiphy();
builder.setImage(gif.getImageOriginalUrl());
builder.setFooter("GIF provided by Giphy API", "https://cdn.discordapp.com/attachments/304027425509998593/373674151472267265/Poweredby_640px_Badge.gif");
builder.setColor(color);
event.reply(new MessageBuilder().append(title).setEmbed(builder.build()).build());
}
示例10: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
protected void execute(CommandEvent event)
{
try
{
Color color;
if(event.isFromType(ChannelType.PRIVATE))
color = Color.decode("#33ff00");
else
color = event.getMember().getColor();
EmbedBuilder builder = new EmbedBuilder();
OkHttpClient client = new OkHttpClient();
Request req = new Request.Builder().url("https://random.cat/meow").get().build();
Response res = client.newCall(req).execute();
if(!res.isSuccessful())
throw new RuntimeException("Error while fetching remote resource");
ResponseBody body = res.body();
String data = body.string();
JSONObject json = new JSONObject(data);
String cat = json.getString("file");
builder.setAuthor("Requested by "+event.getAuthor().getName(), null, event.getAuthor().getEffectiveAvatarUrl());
builder.setImage(cat);
builder.setFooter("Image provided by random.cat API", null);
builder.setColor(color);
event.reply(builder.build());
}
catch(IOException | RuntimeException e)
{
event.replyError("An error was thrown when getting the image! Ask the Owner to check the Console.");
LOG.error(e.getMessage());
if (config.isDebugEnabled())
e.printStackTrace();
}
}
示例11: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
Color color;
EmbedBuilder builder = new EmbedBuilder();
StringBuilder sb = new StringBuilder();
List<User> list = db.getUsersThatDonated(event.getJDA());
if(event.isFromType(ChannelType.PRIVATE))
color = Color.decode("#33ff00");
else
color = event.getGuild().getSelfMember().getColor();
if(list.isEmpty())
sb.append("None has donated yet ):");
else
for(User user : list)
sb.append(String.format("%#s - %s\n", user, db.getAmount(user)));
builder.setColor(color);
builder.addField(":moneybag: Donations:", "Actually, I host Endless on a very basic VPS, which can cause some lag sometimes.\n"
+ "I'll appreciate your donation. All the recauded money will be for get a new and better VPS.\n", false);
builder.addField(":money_mouth: How to donate:", "If you want donate please go to **https://paypal.me/artuto**\n"
+ "You'll get a special role on my server and some perks!", false);
builder.addField(":heart: Donators:", sb.toString(), false);
event.reply(new MessageBuilder().append(":information_source: List of donators:").setEmbed(builder.build()).build());
}
示例12: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
String title = ":information_source: Stats of **"+event.getSelfUser().getName()+"**:";
Color color;
String os = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getName();
String arch = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getArch();
String version = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getVersion();
os = os+" "+arch+" "+version;
int cpus = Runtime.getRuntime().availableProcessors();
String processCpuLoad = new DecimalFormat("###.###%").format(ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getProcessCpuLoad());
String systemCpuLoad = new DecimalFormat("###.###%").format(ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getSystemCpuLoad());
long ramUsed = ((Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()) / (1024 * 1024));
if(event.isFromType(ChannelType.PRIVATE))
color = Color.decode("#33ff00");
else
color = event.getGuild().getSelfMember().getColor();
EmbedBuilder builder = new EmbedBuilder();
builder.addField("<:windows:371075985996775425> OS: ", os, true);
builder.addField(":computer: RAM usage: ", ramUsed+"MB", true);
builder.addField(":gear: CPU usage: ", processCpuLoad+" / "+systemCpuLoad+" ("+cpus+" Cores)", true);
builder.addField(":map: Guilds: ", ""+event.getJDA().getGuilds().size() , true);
builder.addField(":speech_balloon: Text Channels: ", ""+event.getJDA().getTextChannels().size(), true);
builder.addField(":speaker: Voice Channels: ", ""+event.getJDA().getVoiceChannels().size(), true);
builder.addField(":bust_in_silhouette: Users: ", ""+event.getJDA().getUsers().size(), true);
builder.setFooter(event.getSelfUser().getName(), event.getSelfUser().getEffectiveAvatarUrl());
builder.setColor(color);
event.getChannel().sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
}
示例13: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (event.getGuild().getAudioManager().isConnected()) {
if (!event.getArgs().isEmpty()) {
try {
boolean ok = Constant.music.getGuildAudioPlayer(event.getGuild()).scheduler.changeVolume(Integer.parseInt(event.getArgs()));
if (!ok) {
event.replyWarning(event.getMember().getAsMention() + " Usage : `volume 1 - 150`");
}else{
event.reactSuccess();
}
} catch (Exception e) {
event.replyWarning(event.getMember().getAsMention() + " Usage : `volume 1 - 150`");
}
} else {
event.reply("Volume: "+Constant.music.getGuildAudioPlayer(event.getGuild()).scheduler.getVolume());
}
} else {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
}
示例14: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
// use Unirest to poll an API
Unirest.get("http://random.cat/meow").asJsonAsync(new Callback<JsonNode>() {
// The API call was successful
@Override
public void completed(HttpResponse<JsonNode> hr) {
event.reply(new EmbedBuilder()
.setColor(event.isFromType(ChannelType.TEXT) ? event.getSelfMember().getColor() : Color.GREEN)
.setImage(hr.getBody().getObject().getString("file"))
.build());
}
// The API call failed
@Override
public void failed(UnirestException ue) {
event.reactError();
}
// The API call was cancelled (this should never happen)
@Override
public void cancelled() {
event.reactError();
}
});
}
示例15: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
// use Unirest to poll an API
Unirest.get("https://random.dog/woof.json").asJsonAsync(new Callback<JsonNode>() {
// The API call was successful
@Override
public void completed(HttpResponse<JsonNode> hr) {
event.reply(new EmbedBuilder()
.setColor(event.isFromType(ChannelType.TEXT) ? event.getSelfMember().getColor() : Color.GREEN)
.setImage(hr.getBody().getObject().getString("url"))
.build());
}
// The API call failed
@Override
public void failed(UnirestException ue) {
event.reactError();
}
// The API call was cancelled (this should never happen)
@Override
public void cancelled() {
event.reactError();
}
});
}