当前位置: 首页>>代码示例>>Java>>正文


Java CommandEvent类代码示例

本文整理汇总了Java中com.jagrosh.jdautilities.commandclient.CommandEvent的典型用法代码示例。如果您正苦于以下问题:Java CommandEvent类的具体用法?Java CommandEvent怎么用?Java CommandEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommandEvent类属于com.jagrosh.jdautilities.commandclient包,在下文中一共展示了CommandEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reply

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
public void reply(Config config, CommandEvent commandEvent, String message, int numberOfSecondsBeforeRemove,
                  LocaleService localeService) {
    // Give the caller some slack but not much
    Validate.isTrue(numberOfSecondsBeforeRemove > 5);
    if (config != null && config.getReplyInDmWhenPossible()) {
        commandEvent.replyInDM(message);
        commandEvent.reactSuccess();
    } else {
        commandEvent.reactSuccess();
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(message);
        final String msgRemoveText = localeService.getMessageFor(LocaleService.KEEP_CHAT_CLEAN,
                localeService.getLocaleForUser(commandEvent.getAuthor()), "" +
                        numberOfSecondsBeforeRemove);

        embedBuilder.setFooter(msgRemoveText, null);
        sendMessageThenDeleteAfterXSeconds(commandEvent, embedBuilder.build(),
                numberOfSecondsBeforeRemove, TimeUnit.SECONDS);
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:24,代码来源:DefaultFeedbackStrategy.java

示例2: ping

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
protected MCPing.McPing ping(String serverIP, CommandEvent e) {
    EmbedBuilder eb = new EmbedBuilder();
    String[] ipPort = serverIP.split(":");
    if (ipPort.length == 1) {
        return MCPing.pingPc(ipPort[0], 25565, true);
    } else if (ipPort.length == 2) {
        try {
            return MCPing.pingPc(ipPort[0], Integer.parseInt(ipPort[1]), true);
        } catch (NumberFormatException ex) {
            eb.setDescription("Error getting server info: `java.lang.NumberFormatException`");
            respond(e, embedMessage(e, eb.build(), ResponseLevel.LEVEL_3));
            return null;
        }
    } else {
        eb.setDescription(Locale.getCommandsMessage("mcserver.error").finish());
        respond(e, embedMessage(e, eb.build(), ResponseLevel.LEVEL_3));
        return null;
    }
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:20,代码来源:MCBCommand.java

示例3: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    // check that the user provided choices
    if(event.getArgs().isEmpty())
    {
        event.replyWarning("You didn't give me any choices!");
    }
    else
    {
        // split the choices on all whitespace
        String[] items = event.getArgs().split("\\s+");
        
        // if there is only one option, have a special reply
        if(items.length==1)
            event.replyWarning("You only gave me one option, `"+items[0]+"`");
        
        // otherwise, pick a random response
        else
        {
            event.replySuccess("I choose `"+items[(int)(Math.random()*items.length)]+"`");
        }
    }
}
 
开发者ID:jagrosh,项目名称:ExampleBot,代码行数:25,代码来源:ChooseCommand.java

示例4: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void execute(CommandEvent e) {
    if (C.hasRole(e.getMember(), Roles.HELPER)) {
        if (e.getMessage().getMentionedUsers().size() == 1) {
            Member u = C.getMentionedMember(e);
            if (C.hasRole(u, Roles.EXP_SPAMMER)) {
                C.removeRole(u, Roles.EXP_SPAMMER);
                e.replySuccess(u.getUser().getAsMention() + " is no longer an EXP Spammer!");
            } else {
                C.giveRole(u, Roles.EXP_SPAMMER);
                e.replySuccess(u.getUser().getAsMention() + " has become an EXP Spammer!");
                C.privChannel(C.getMentionedMember(e), "You have become an EXP Spammer! Please ask to get this removed 1 week from now!");
            }
        } else {
            e.replyError("**Correct Usage:** ^" + name + " " + arguments);
        }
    } else {
        e.replyError(C.permMsg(Roles.HELPER));
    }
}
 
开发者ID:WheezyGold7931,项目名称:happybot,代码行数:21,代码来源:SpamCommand.java

示例5: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    String prefix = event.getClient().getPrefix();

    if(event.getArgs().isEmpty())
    {
        event.replyWarning("Please choose a subcommand:\n" +
                "- `"+prefix+"blacklistuser add`: Adds a user ID to the blacklisted users list.\n" +
                "- `"+prefix+"blacklistuser remove`: Removes a user ID from the blacklisted users list.\n" +
                "- `"+prefix+"blacklistuser list`: Displays blacklisted users.\n" +
                "- `"+prefix+"blacklistuser check`: Checks if a user ID is blacklisted.");
    }
    else if(!(event.getArgs().contains("add")) || !(event.getArgs().contains("remove")) || !(event.getArgs().contains("list") || !(event.getArgs().contains("check"))))
    {
        event.replyWarning("Please choose a subcommand:\n" +
                "- `"+prefix+"blacklistuser add`: Adds a user ID to the blacklisted users list.\n" +
                "- `"+prefix+"blacklistuser remove`: Removes a user ID from the blacklisted users list.\n" +
                "- `"+prefix+"blacklistuser list`: Displays blacklisted users.\n" +
                "- `"+prefix+"blacklistuser check`: Checks if a user ID is blacklisted.");
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:23,代码来源:BlacklistUsers.java

示例6: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void execute(CommandEvent e) {
    if (C.hasRole(e.getMember(), Roles.MODERATOR)) {
        String[] args = e.getArgs().split(" ");
        if (e.getArgs().length() > 2) {
            if (args.length >= 1) {
                C.getCtrl(e).unban(args[0]).reason("Pardoned by Moderator: " + e.getMember().getUser().getName()).queue();
                e.replySuccess("User U(" + args[0] + ") has been *forgivably pardoned*  by " + e.getMember().getEffectiveName());
            } else {
                e.replyError("**Correct Usage:** ^" + name + " " + arguments);
            }
        } else {
            e.replyError("**Correct Usage:** ^" + name + " " + arguments);
        }
    } else {
        e.replyError(C.permMsg(Roles.MODERATOR));
    }
}
 
开发者ID:WheezyGold7931,项目名称:happybot,代码行数:19,代码来源:PardonCommand.java

示例7: replyError

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
public void replyError(Config config, CommandEvent commandEvent, Throwable throwable, LocaleService localeService) {
    if (config != null && config.getReplyInDmWhenPossible()) {
        commandEvent.replyInDM(throwable.getMessage());
        commandEvent.reactError();
        handleOriginMessage(commandEvent);
    } else {
        commandEvent.reactError();
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(throwable.getMessage());
        final String msgRemoveText = localeService.getMessageFor(LocaleService.ERROR_KEEP_CHAT_CLEAN,
                localeService.getLocaleForUser(commandEvent.getAuthor()),
                String.valueOf(BotServerMain.timeToRemoveFeedbackInSeconds));
        embedBuilder.setFooter(msgRemoveText, null);
        final MessageEmbed messageEmbed = embedBuilder.build();
        replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed,
                BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS);
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:22,代码来源:CleanUpMostFeedbackStrategy.java

示例8: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void execute(CommandEvent e) {
    if (C.hasRole(e.getMember(), Roles.ADMIN)) {
        e.reply("Loading...");
        int affected = 0;
        for (Member curM : C.getGuild().getMembers()) {
            if (!C.hasRole(curM, Roles.FANS) && !curM.getUser().isBot()) {
                C.giveRole(curM, Roles.FANS);
                affected++;
            }
        }
        e.replySuccess("All Done!\n" + String.valueOf(affected) + " Users Affected!");
    } else {
        e.replyError(C.permMsg(Roles.ADMIN));
    }
}
 
开发者ID:WheezyGold7931,项目名称:happybot,代码行数:17,代码来源:FansCommand.java

示例9: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void execute(CommandEvent e) {
    if (C.hasRole(e.getMember(), Roles.ADMIN)) {

        try {
            PermissionOverride permissionOverride = e.getTextChannel().getPermissionOverride(Roles.EVERYONE.getRole());
            PermOverrideManager manager = permissionOverride.getManager();
            manager.deny(Permission.MESSAGE_WRITE).queue();
            e.replySuccess(":lock: Channel has been locked!");
        } catch (NullPointerException npe) {
            e.replyError("An error occurred while locking the channel! Please make sure this channel is setup correctly.");
        }


    } else {
        e.replyError(C.permMsg(Roles.ADMIN));
    }
}
 
开发者ID:WheezyGold7931,项目名称:happybot,代码行数:19,代码来源:LockCommand.java

示例10: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    if(event.getArgs().isEmpty())
    {
        event.replyWarning("Specify a tag name!");
        return;
    }

    String tag = db.getTagContent(event.getArgs().trim().toLowerCase());
    User owner = event.getJDA().retrieveUserById(db.getTagOwner(event.getArgs())).complete();

    if(tag==null)
        event.replyError("No tag found with that name!");
    else
        event.reply("The owner of the tag `"+event.getArgs().trim().toLowerCase()+"` is **"+owner.getName()+"#"+owner.getDiscriminator()+"** (ID: **"+owner.getId()+"**)");
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:18,代码来源:Tag.java

示例11: executeWithConfig

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    String pokemonName = commandEvent.getArgs();
    final Pokemon pokemon = repo.search(pokemonName, commandEvent.getAuthor());
    final RaidBossCounters counters = raidInfoService.getCounters(pokemon);
    final String maxCp = raidInfoService.getMaxCp(pokemon);
    StringBuilder builder = new StringBuilder();
    final Locale localeForUser = localeService.getLocaleForUser(commandEvent.getAuthor());
    builder.append("**").append(pokemon).append("**\n");
    builder.append(localeService.getMessageFor(LocaleService.WEAKNESSES, localeForUser))
            .append(Utils.printWeaknesses(pokemon)).append("\n").append(
            localeService.getMessageFor(LocaleService.RESISTANT, localeForUser))
            .append(pokemon.getResistant());

    if (counters != null) {
        builder.append("\n");
        appendBestCounters(counters, builder, localeForUser);
    }

    if (maxCp != null) {
        builder.append("\nMax CP level 20 (100% IV): ").append(maxCp).append("\n");
    }

    replyBasedOnConfig(config, commandEvent, builder.toString());
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:26,代码来源:PokemonVsCommand.java

示例12: 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:");
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:27,代码来源:PlayCommand.java

示例13: removeTextChannel

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
private void removeTextChannel(CommandEvent e) {
    String arg = e.getArgs();
    String response;
    boolean withID = StringUtils.isNumeric(arg);
    java.util.List<TextChannel> tcArray = mcb.getRelayChannels();
    String tcID = withID ? arg : FinderUtil.findTextChannel(arg, e.getGuild()).get(0).getId();
    if (!containsID(tcID)) {
        response = Locale.getCommandsMessage("textchannel.tc-not-bound").finish();
        respond(e, String.format(response, arg), ResponseLevel.LEVEL_2);
        return;
    }
    if (tcArray.size() == 1) {
        response = Locale.getCommandsMessage("textchannel.last-tc").finish();
        respond(e, String.format(response, arg), ResponseLevel.LEVEL_2);
        return;
    }
    tcArray.remove(mcb.getBot().getJda().getTextChannelById(tcID));
    configsManager.getChatConfig().set("Relay_Channels", tcArray);
    configsManager.getChatConfig().saveConfig();
    response = Locale.getCommandsMessage("textchannel.removed-tc").finish();
    respond(e, String.format(response, arg), ResponseLevel.LEVEL_1);
    Logger.info("Removed text channel " + arg);
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:24,代码来源:TextChannelCmd.java

示例14: replyAndKeep

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
public void replyAndKeep(Config config, CommandEvent commandEvent, String message) {
    if (config != null && config.getReplyInDmWhenPossible()) {
        commandEvent.replyInDM(message);
        commandEvent.reactSuccess();
        handleOriginMessage(commandEvent);
    } else {
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(message);
        final MessageEmbed messageEmbed = embedBuilder.build();
        replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent,
                messageEmbed, BotServerMain.timeToRemoveFeedbackInSeconds * 3, TimeUnit.SECONDS);
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:17,代码来源:CleanUpMostFeedbackStrategy.java

示例15: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event) {
    Properties p = Constant.getTextChannelConf();
    if (p.getProperty(event.getGuild().getId()) == null) {
        p.put(event.getGuild().getId(), "");
    }
    if (event.getArgs().isEmpty()) {
        p.replace(event.getGuild().getId(), event.getChannel().getId());
    } else {
        try {
            Constant.getVoiceChannelConf().getProperty(event.getGuild().getId());
            p.remove(event.getGuild().getId());
        } catch (Exception e) {
            event.replyError("Please unset the voice channel first.\nSee `"+Constant.prefix+"help setVoiceChannel`");
        }
    }
    Constant.writeTextChannelConf(p);
    event.reactSuccess();
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:20,代码来源:SetTextChannelCommand.java


注:本文中的com.jagrosh.jdautilities.commandclient.CommandEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。