use of me.shadorc.shadbot.command.admin.setting.core.SettingEnum in project Shadbot by Shadorc.
the class DBGuild method toJSON.
public JSONObject toJSON() {
JSONObject guildObj = new JSONObject();
JSONObject settingsObj = new JSONObject();
for (SettingEnum setting : settingsMap.keySet()) {
settingsObj.put(setting.toString(), settingsMap.get(setting));
}
guildObj.put(SETTINGS_KEY, settingsObj);
this.loadUsers();
JSONObject usersObj = new JSONObject();
for (Long userID : usersMap.keySet()) {
usersObj.put(userID.toString(), usersMap.get(userID).toJSON());
}
guildObj.put(USERS_KEY, usersObj);
return guildObj;
}
use of me.shadorc.shadbot.command.admin.setting.core.SettingEnum in project Shadbot by Shadorc.
the class SettingsCmd method execute.
@Override
public void execute(Context context) throws MissingArgumentException, IllegalCmdArgumentException {
List<String> splitArgs = StringUtils.split(context.getArg(), 2);
if (splitArgs.isEmpty()) {
throw new MissingArgumentException();
}
SettingEnum settingEnum = Utils.getValueOrNull(SettingEnum.class, splitArgs.get(0));
if (settingEnum == null || !SETTINGS_MAP.containsKey(settingEnum)) {
throw new IllegalCmdArgumentException(String.format("Setting `%s` does not exist. Use `%shelp %s` to see all available settings.", splitArgs.get(0), context.getPrefix(), this.getName()));
}
AbstractSetting setting = SETTINGS_MAP.get(settingEnum);
String arg = splitArgs.size() == 2 ? splitArgs.get(1) : null;
if ("help".equals(arg)) {
BotUtils.sendMessage(this.getHelp(context.getPrefix(), setting), context.getChannel());
return;
}
try {
setting.execute(context, arg);
} catch (MissingArgumentException e) {
BotUtils.sendMessage(new MessageBuilder(context.getClient()).withChannel(context.getChannel()).withContent(TextUtils.MISSING_ARG).withEmbed(this.getHelp(context.getPrefix(), setting)));
}
}
Aggregations