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


Java CommandEvent.getArgs方法代码示例

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


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

示例1: execute

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

    if(args.isEmpty())
    {
        event.replyWarning("Please specify a timezone!");
        return;
    }

    try
    {
        ZoneId.of(args);
    }
    catch(ZoneRulesException e)
    {
        event.replyError("Please specify a valid timezone!");
        return;
    }

    db.setTimezone(event.getAuthor(), args);
    event.replySuccess("Successfully updated timezone!");
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:25,代码来源:TimeFor.java

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

示例3: addTextChannel

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
private void addTextChannel(CommandEvent e) {
    String arg = e.getArgs();
    java.util.List<TextChannel> tcArray = mcb.getRelayChannels();
    String response;
    boolean withID = StringUtils.isNumeric(arg) && e.getJDA().getTextChannelById(arg) != null;
    TextChannel tc;
    if (withID) {
        tc = e.getJDA().getTextChannelById(arg);
    } else {
        java.util.List<TextChannel> result = FinderUtil.findTextChannel(arg, e.getGuild());
        tc = result.size() > 0 ? result.get(0) : null;
    }
    if (tc != null) {
        tcArray.add(tc);
        configsManager.getChatConfig().set("Relay_Channels", asStringList(tcArray));
        configsManager.getChatConfig().saveConfig();
    } else {
        response = Locale.getCommandsMessage("textchannel.invalid-tc").finish();
        respond(e, String.format(response, arg), ResponseLevel.LEVEL_3);
        return;
    }
    response = Locale.getCommandsMessage("textchannel.added-tc").finish();
    respond(e, String.format(response, arg), ResponseLevel.LEVEL_1);
    Logger.info("Added text channel " + arg);
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:26,代码来源:TextChannelCmd.java

示例4: 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

示例5: 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

示例6: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
     if(event.getArgs().isEmpty())
     {
         event.replyError("Please provide me a valid OnlineStatus!");
         return;
     }
     
     if(event.getArgs().equals("help"))
     {
         event.replyInDM("Help for subcommand `bot status`\n"
                 + "Valid options: `ONLINE`, `DO_NOT_DISTURB`, `INVISIBLE`, `AWAY`");
         event.reactSuccess();
         return;
     }
     
     try
     {
        String status = event.getArgs();
        event.getJDA().getPresence().setStatus(OnlineStatus.valueOf(status));
        event.replySuccess("Changed status to "+event.getJDA().getPresence().getStatus()+" without error!");
     }
     catch(Exception e)
     {
         event.replyError("Error when changing the status! Check the Bot console for more information.");
         e.printStackTrace();
     }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:30,代码来源:BotCPanel.java

示例7: 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());
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:38,代码来源:GiphyGif.java

示例8: doCommand

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void doCommand(CommandEvent event)
{
    Guild guild = event.getGuild();
    String args = event.getArgs();
    if(args.isEmpty())
        fail(event, getUsageEmbed(guild));

    MessageEmbed usage = MDCBot.getCommandUsage(guild, args);
    reply(event, usage != null ? usage : Util.createBotMessage(guild, "Command has no usage description"));
}
 
开发者ID:thebrightspark,项目名称:MDC-Discord-Bot,代码行数:12,代码来源:CommandUsage.java

示例9: doCommand

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void doCommand(CommandEvent event)
{
    if(MDCBot.mutedRole == null)
    {
        fail(event, "No muted role. Set one using the command:\n" +
                "%s config %s <role name>", MDCBot.PREFIX, EConfigs.MUTED_ROLE);
        return;
    }

    String args = event.getArgs();
    if(args.isEmpty())
    {
        fail(event, "Must provide a member to mute");
        return;
    }

    Guild guild = event.getGuild();
    Member member = getMemberFromString(event, guild, args);

    if(member == null) return;
    if(member.getRoles().contains(MDCBot.mutedRole))
    {
        if(MuteHandler.unmuteMember(member))
        {
            //Unmuted member
            info(event, "%s has been unmuted", member.getEffectiveName());
            reply(event, "%s (%s) has been unmuted", member.getEffectiveName(), member.getRoles().get(0).getName());
        }
        else
        {
            //Member is not muted
            warn(event, "%s is not muted", member.getEffectiveName());
            reply(event, "%s (%s) is not muted", member.getEffectiveName(), member.getRoles().get(0).getName());
        }
    }
}
 
开发者ID:thebrightspark,项目名称:MDC-Discord-Bot,代码行数:38,代码来源:CommandUnmute.java

示例10: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent cmdEvent) {
    GGDCommandEvent event = new GGDCommandEvent(cmdEvent.getEvent(), cmdEvent.getArgs(), cmdEvent.getClient());

    if (!allowedInGuild && event.getChannelType() == ChannelType.TEXT) {
        event.replyErrorInDM("Diesen Befehl bitte hier ausführen!");
        event.getMessage().delete().queue();
        return;
    }

    executeCommand(event);
}
 
开发者ID:michidk,项目名称:GGD-Discord-Bot,代码行数:13,代码来源:GGDCommand.java

示例11: doCommand

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void doCommand(CommandEvent e) {
    String trigger = e.getArgs();
    if(trigger.contains("\\")) {
        respond(e, Locale.getCommandsMessage("settrigger.invalid").finish());
        return;
    }
    configsManager.getBotConfig().set("Command_Trigger", trigger);
    configsManager.getBotConfig().saveConfig();
    respond(e, Locale.getCommandsMessage("settrigger.changed").finish());
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:12,代码来源:SetTriggerCmd.java

示例12: doCommand

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void doCommand(CommandEvent event) {
    String arg = event.getArgs();
    arg = arg.replaceAll("```js", "");
    arg = arg.replaceAll("```", "");
    if (event.getArgs().isEmpty()) {
        event.replyInDM(event.getClient().getError() + " please provide something to evaluate");
        return;
    }

    ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("Nashorn");
    scriptEngine.put("mcb", mcb);
    scriptEngine.put("event", event);
    scriptEngine.put("jda", event.getJDA());
    scriptEngine.put("guild", event.getGuild());
    scriptEngine.put("cfgMngr", mcb.getMcbConfigsManager());
    scriptEngine.put("channel", event.getTextChannel());
    scriptEngine.put("server", Bukkit.getServer());
    StringBuilder builder = new StringBuilder();
    try {
        builder.append("**Result**: ").append(scriptEngine.eval(arg.trim()));
        respond(builder.toString(), event).queue();
    } catch (Exception e1) {
        builder = new StringBuilder();
        builder.append("**Error**: ").append(e1.getClass().getSimpleName()).append("\n");
        builder.append("**Cause**: \n").append(e1.getCause().toString());
        respond(builder.toString(), event).queue();
    }
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:30,代码来源:EvalCmd.java

示例13: doCommand

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void doCommand(CommandEvent event) {
    String url;
    if (event.getArgs().isEmpty())
        if (!event.getMessage().getAttachments().isEmpty() && event.getMessage().getAttachments().get(0).isImage())
            url = event.getMessage().getAttachments().get(0).getUrl();
        else
            url = null;
    else
        url = event.getArgs();
    InputStream s = OtherUtil.imageFromUrl(url);
    if (s == null) {
        respond(event, event.getClient().getError() +
            " " + Locale.getCommandsMessage("setavatar.invalid").finish());
    } else {
        try {
            event.getSelfUser().getManager().setAvatar(Icon.from(s)).queue(
                    v -> respond(event, event.getClient().getSuccess() + " " +
                            Locale.getCommandsMessage("setavatar.changed").finish()),
                    t -> respond(event,event.getClient().getError() + " " +
                            Locale.getCommandsMessage("setavatar.failed").finish()));
        } catch (IOException e) {
            respond(event, event.getClient().getError() + " " +
                    Locale.getCommandsMessage("setavatar.couldNotLoad").finish());
        }
    }
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:28,代码来源:SetAvatarCmd.java

示例14: executeWithConfig

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    String gymName = commandEvent.getArgs();
    final Gym gym = gymRepository.search(commandEvent.getAuthor(), gymName, config.getRegion());
    String staticUrl = Utils.getStaticMapUrl(gym);
    String nonStaticUrl = Utils.getNonStaticMapUrl(gym);
    replyMapBasedOnConfig(config, commandEvent,
            new EmbedBuilder().setImage(staticUrl).setTitle(gym.getName(), nonStaticUrl).build());
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:10,代码来源:WhereIsGymCommand.java

示例15: executeWithConfig

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    String gymName = commandEvent.getArgs();
    final Gym gym = gymRepository.search(commandEvent.getAuthor(), gymName, config.getRegion());
    String staticUrl = Utils.getStaticMapUrl(gym);
    String nonStaticUrl = Utils.getNonStaticMapUrl(gym);
    final MessageEmbed messageEmbed = new EmbedBuilder().setImage(staticUrl).setTitle(gym.getName(), nonStaticUrl)
            .build();
    replyMapInChat(config, commandEvent, messageEmbed);
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:11,代码来源:WhereIsGymInChatCommand.java


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