Search in sources :

Example 36 with MissingArgumentException

use of me.shadorc.shadbot.exception.MissingArgumentException in project Shadbot by Shadorc.

the class AutoMessageSetting method updateJoinMessage.

private void updateJoinMessage(Context context, Action action, List<String> args) throws MissingArgumentException {
    DBGuild dbGuild = Database.getDBGuild(context.getGuild());
    if (Action.ENABLE.equals(action)) {
        if (args.size() < 3) {
            throw new MissingArgumentException();
        }
        String message = args.get(2);
        dbGuild.setSetting(SettingEnum.JOIN_MESSAGE, message);
        BotUtils.sendMessage(String.format(Emoji.CHECK_MARK + " Join message set to `%s`", message), context.getChannel());
    } else if (Action.DISABLE.equals(action)) {
        dbGuild.removeSetting(SettingEnum.JOIN_MESSAGE);
        BotUtils.sendMessage(Emoji.CHECK_MARK + " Join message disabled.", context.getChannel());
    }
}
Also used : DBGuild(me.shadorc.shadbot.data.db.DBGuild) MissingArgumentException(me.shadorc.shadbot.exception.MissingArgumentException)

Aggregations

MissingArgumentException (me.shadorc.shadbot.exception.MissingArgumentException)36 IllegalCmdArgumentException (me.shadorc.shadbot.exception.IllegalCmdArgumentException)22 EmbedBuilder (sx.blah.discord.util.EmbedBuilder)15 IOException (java.io.IOException)11 Context (me.shadorc.shadbot.core.command.Context)10 LoadingMessage (me.shadorc.shadbot.utils.object.LoadingMessage)10 List (java.util.List)9 FormatUtils (me.shadorc.shadbot.utils.FormatUtils)9 AbstractCommand (me.shadorc.shadbot.core.command.AbstractCommand)8 CommandCategory (me.shadorc.shadbot.core.command.CommandCategory)8 Command (me.shadorc.shadbot.core.command.annotation.Command)8 BotUtils (me.shadorc.shadbot.utils.BotUtils)8 StringUtils (me.shadorc.shadbot.utils.StringUtils)8 HelpBuilder (me.shadorc.shadbot.utils.embed.HelpBuilder)8 EmbedObject (sx.blah.discord.api.internal.json.objects.EmbedObject)8 DBGuild (me.shadorc.shadbot.data.db.DBGuild)7 EmbedUtils (me.shadorc.shadbot.utils.embed.EmbedUtils)7 Emoji (me.shadorc.shadbot.utils.object.Emoji)7 JSONArray (org.json.JSONArray)7 JSONException (org.json.JSONException)7