Search in sources :

Example 1 with MantaroObj

use of net.kodehawa.mantarobot.data.entities.MantaroObj in project MantaroBot by Mantaro.

the class OwnerCmd method blacklist.

@Command
public static void blacklist(CommandRegistry cr) {
    cr.register("blacklist", new SimpleCommand(Category.OWNER, CommandPermission.OWNER) {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
            MantaroObj obj = MantaroData.db().getMantaroData();
            if (args[0].equals("guild")) {
                if (args[1].equals("add")) {
                    if (MantaroBot.getInstance().getGuildById(args[2]) == null)
                        return;
                    obj.getBlackListedGuilds().add(args[2]);
                    event.getChannel().sendMessage(EmoteReference.CORRECT + "Blacklisted Guild: " + event.getJDA().getGuildById(args[2])).queue();
                    obj.save();
                } else if (args[1].equals("remove")) {
                    if (!obj.getBlackListedGuilds().contains(args[2]))
                        return;
                    obj.getBlackListedGuilds().remove(args[2]);
                    event.getChannel().sendMessage(EmoteReference.CORRECT + "Unblacklisted Guild: " + args[2]).queue();
                    obj.save();
                }
                return;
            }
            if (args[0].equals("user")) {
                if (args[1].equals("add")) {
                    if (MantaroBot.getInstance().getUserById(args[2]) == null)
                        return;
                    obj.getBlackListedUsers().add(args[2]);
                    event.getChannel().sendMessage(EmoteReference.CORRECT + "Blacklisted User: " + event.getJDA().getUserById(args[2])).queue();
                    obj.save();
                } else if (args[1].equals("remove")) {
                    if (!obj.getBlackListedUsers().contains(args[2]))
                        return;
                    obj.getBlackListedUsers().remove(args[2]);
                    event.getChannel().sendMessage(EmoteReference.CORRECT + "Unblacklisted User: " + event.getJDA().getUserById(args[2])).queue();
                    obj.save();
                }
            }
        }

        @Override
        public MessageEmbed help(GuildMessageReceivedEvent event) {
            return helpEmbed(event, "Blacklist command").setDescription("**Blacklists a user (user argument) or a guild (guild argument) by id.**").setFooter("Examples", "~>blacklist user add/remove 293884638101897216\n" + "~>blacklist guild add/remove 305408763915927552").build();
        }
    });
}
Also used : MessageEmbed(net.dv8tion.jda.core.entities.MessageEmbed) SimpleCommand(net.kodehawa.mantarobot.modules.commands.SimpleCommand) MantaroObj(net.kodehawa.mantarobot.data.entities.MantaroObj) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) SimpleCommand(net.kodehawa.mantarobot.modules.commands.SimpleCommand) Command(net.kodehawa.mantarobot.modules.Command)

Aggregations

MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)1 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)1 MantaroObj (net.kodehawa.mantarobot.data.entities.MantaroObj)1 Command (net.kodehawa.mantarobot.modules.Command)1 SimpleCommand (net.kodehawa.mantarobot.modules.commands.SimpleCommand)1