use of net.kodehawa.mantarobot.modules.commands.base.Command in project MantaroBot by Mantaro.
the class CommandRegistry method process.
public boolean process(GuildMessageReceivedEvent event, String cmdname, String content) {
Command cmd = commands.get(cmdname);
Config conf = MantaroData.config().get();
DBGuild dbg = MantaroData.db().getGuild(event.getGuild());
GuildData data = dbg.getData();
if (cmd == null)
return false;
if (data.getDisabledCommands().contains(cmdname)) {
return false;
}
if (data.getChannelSpecificDisabledCommands().get(event.getChannel().getId()) != null && data.getChannelSpecificDisabledCommands().get(event.getChannel().getId()).contains(cmdname)) {
return false;
}
if (data.getDisabledUsers().contains(event.getAuthor().getId())) {
return false;
}
if (MantaroData.db().getGuild(event.getGuild()).getData().getDisabledChannels().contains(event.getChannel().getId()) && cmd.category() != Category.MODERATION) {
return false;
}
if (MantaroData.config().get().isPremiumBot() && cmd.category() == Category.CURRENCY) {
return false;
}
if (data.getDisabledCategories().contains(cmd.category())) {
return false;
}
//If we are in the patreon bot, deny all requests from unknown guilds.
if (conf.isPremiumBot() && !conf.isOwner(event.getAuthor()) && !dbg.isPremium()) {
event.getChannel().sendMessage(EmoteReference.ERROR + "Seems like you're trying to use the Patreon bot when this guild is **not** marked as premium. " + "**If you think this is an error please contact Kodehawa#3457 or poke me on #donators in the support guild**").queue();
return false;
}
if (!cmd.permission().test(event.getMember())) {
event.getChannel().sendMessage(EmoteReference.STOP + "You have no permissions to trigger this command").queue();
return false;
}
cmd.run(event, cmdname, content);
return true;
}
use of net.kodehawa.mantarobot.modules.commands.base.Command in project MantaroBot by Mantaro.
the class TreeCommand method run.
/**
* Invokes the command to be executed.
*
* @param event the event that triggered the command
* @param commandName the command name that was used
* @param content the arguments of the command
*/
@Override
public void run(GuildMessageReceivedEvent event, String commandName, String content) {
String[] args = splitArgs(content, 2);
Command command = subCommands.get(args[0]);
if (command == null)
command = onNotFound(event, args[0]);
if (command == null)
return;
command.run(event, commandName + " " + args[0], args[1]);
}
Aggregations