Search in sources :

Example 1 with Command

use of tk.ardentbot.core.executor.Command in project Ardent by adamint.

the class Restrict method setupSubcommands.

@Override
public void setupSubcommands() throws Exception {
    subcommands.add(new Subcommand("Prevent a user from using Ardent commands", "block @User", "block") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            Member member = guild.getMember(user);
            if (member.hasPermission(Permission.MANAGE_SERVER)) {
                List<User> mentionedUsers = message.getMentionedUsers();
                if (mentionedUsers.size() > 0) {
                    for (User mentioned : mentionedUsers) {
                        Member mentionedMember = guild.getMember(mentioned);
                        if (mentionedMember.hasPermission(member.getPermissions()) || mentionedMember.hasPermission(Permission.MANAGE_SERVER) || mentionedMember.getUser().getId().equalsIgnoreCase(guild.getSelfMember().getUser().getId())) {
                            sendTranslatedMessage("You cannot modify this user because they have the same or higher permissions than " + "you.", channel, user);
                            return;
                        }
                        EntityGuild entityGuild = EntityGuild.get(guild);
                        boolean isRestricted = entityGuild.isRestricted(mentioned);
                        if (isRestricted) {
                            sendTranslatedMessage("This user has already been blocked from using commands!", channel, user);
                        } else {
                            RestrictedUser restrictedUser = new RestrictedUser(mentioned.getId(), user.getId(), guild);
                            entityGuild.addRestricted(restrictedUser);
                            r.db("data").table("restricted").insert(r.json(gson.toJson(new RestrictedUserModel(guild.getId(), mentioned.getId(), user.getId())))).run(connection);
                            sendEditedTranslation("{1} has blocked {0} from sending commands", user, channel, mentioned.getName(), user.getName());
                        }
                    }
                } else
                    sendTranslatedMessage("You need to mention one or more users", channel, user);
            } else
                sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
        }
    });
    subcommands.add(new Subcommand("Allow a blocked user to run Ardent commands again", "unblock @User", "unblock") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            if (guild.getMember(user).hasPermission(Permission.MANAGE_SERVER)) {
                List<User> mentionedUsers = message.getMentionedUsers();
                if (mentionedUsers.size() > 0) {
                    for (User mentioned : mentionedUsers) {
                        EntityGuild entityGuild = EntityGuild.get(guild);
                        boolean isRestricted = entityGuild.isRestricted(mentioned);
                        if (!isRestricted) {
                            sendEditedTranslation("{0} isn't restricted from sending commands!", user, channel, mentioned.getName());
                        } else {
                            entityGuild.removeRestricted(mentioned.getId());
                            r.db("data").table("restricted").filter(row -> row.g("user_id").eq(mentioned.getId()).and(row.g("guild_id").eq(guild.getId()))).delete().run(connection);
                            sendEditedTranslation("{0} unrestricted {1}, allowing them to use commands again", user, channel, mentioned.getName(), user.getName());
                        }
                    }
                } else
                    sendTranslatedMessage("You need to mention one or more users", channel, user);
            } else
                sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
        }
    });
    subcommands.add(new Subcommand("View all the users who have been blocked in your server", "view") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            EntityGuild entityGuild = EntityGuild.get(guild);
            ArrayList<RestrictedUser> restrictedUsers = entityGuild.getRestrictedUsers();
            String title = "Restricted users";
            String restrictedBy = "restricted by";
            StringBuilder response = new StringBuilder();
            response.append("**" + title + "**");
            if (restrictedUsers.size() == 0) {
                response.append("\nNo one");
            } else {
                restrictedUsers.forEach(restrictedUser -> response.append("\n - " + guild.getMemberById(restrictedUser.getUserId()).getUser().getName() + ", " + restrictedBy + " " + guild.getMemberById(restrictedUser.getRestrictedById()).getUser().getName()));
            }
            EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
            builder.setAuthor(title, getShard().url, guild.getSelfMember().getUser().getAvatarUrl());
            builder.setDescription(response.toString());
            sendEmbed(builder, channel, user);
        }
    });
}
Also used : MessageUtils(tk.ardentbot.utils.discord.MessageUtils) Command(tk.ardentbot.core.executor.Command) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) Subcommand(tk.ardentbot.core.executor.Subcommand) RestrictedUserModel(tk.ardentbot.rethink.models.RestrictedUserModel) RestrictedUser(tk.ardentbot.utils.models.RestrictedUser) Database.r(tk.ardentbot.rethink.Database.r) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) ArrayList(java.util.ArrayList) EntityGuild(tk.ardentbot.utils.rpg.EntityGuild) List(java.util.List) Permission(net.dv8tion.jda.core.Permission) Database.connection(tk.ardentbot.rethink.Database.connection) RestrictedUser(tk.ardentbot.utils.models.RestrictedUser) Subcommand(tk.ardentbot.core.executor.Subcommand) ArrayList(java.util.ArrayList) EntityGuild(tk.ardentbot.utils.rpg.EntityGuild) EntityGuild(tk.ardentbot.utils.rpg.EntityGuild) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) ArrayList(java.util.ArrayList) List(java.util.List) RestrictedUserModel(tk.ardentbot.rethink.models.RestrictedUserModel) RestrictedUser(tk.ardentbot.utils.models.RestrictedUser)

Example 2 with Command

use of tk.ardentbot.core.executor.Command in project Ardent by adamint.

the class Music method loadAndPlay.

static void loadAndPlay(Message message, User user, Command command, final TextChannel channel, String trackUrl, final VoiceChannel voiceChannel, boolean search, boolean useEmbedSelect) {
    if (trackUrl.contains("spotify.com")) {
        String[] parsed = trackUrl.split("/track/");
        if (parsed.length == 2) {
            final TrackRequest request = spotifyApi.getTrack(parsed[1]).build();
            try {
                trackUrl = request.get().getName();
            } catch (Exception e) {
                new BotException(e);
            }
        }
    }
    Guild guild = channel.getGuild();
    GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild(), channel);
    String finalTrackUrl = trackUrl;
    GuildUtils.getShard(guild).playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {

        @Override
        public void trackLoaded(AudioTrack track) {
            if (!UserUtils.hasTierTwoPermissions(user) && !EntityGuild.get(guild).isPremium()) {
                try {
                    if (!shouldContinue(user, guild, channel, track)) {
                        return;
                    }
                } catch (Exception e) {
                    new BotException(e);
                }
            }
            try {
                command.sendTranslatedMessage("Adding {0} to the queue".replace("{0}", track.getInfo().title) + " " + getDuration(track), channel, user);
            } catch (Exception e) {
                new BotException(e);
            }
            play(user, guild, voiceChannel, musicManager, track, channel);
        }

        @Override
        public void playlistLoaded(AudioPlaylist playlist) {
            List<AudioTrack> tracks = playlist.getTracks();
            if (playlist.isSearchResult()) {
                try {
                    if (!useEmbedSelect) {
                        AudioTrack[] possible;
                        if (playlist.getTracks().size() >= 5)
                            possible = playlist.getTracks().subList(0, 5).toArray(new AudioTrack[5]);
                        else
                            possible = playlist.getTracks().toArray(new AudioTrack[playlist.getTracks().size()]);
                        ArrayList<String> names = new ArrayList<>();
                        for (AudioTrack audioTrack : possible) {
                            names.add(audioTrack.getInfo().title);
                        }
                        Message embed = command.sendEmbed(command.chooseFromList("Choose Song", guild, user, command, names.toArray(new String[5])), channel, user);
                        interactiveOperation(channel, message, selectionMessage -> {
                            try {
                                AudioTrack selected = possible[Integer.parseInt(selectionMessage.getContent()) - 1];
                                if (!UserUtils.hasTierTwoPermissions(user) && !EntityGuild.get(guild).isPremium()) {
                                    try {
                                        if (!shouldContinue(user, guild, channel, selected)) {
                                            return;
                                        }
                                    } catch (Exception e) {
                                        new BotException(e);
                                    }
                                }
                                try {
                                    embed.delete().queue();
                                    selectionMessage.delete().queue();
                                } catch (Exception ignored) {
                                }
                                play(user, guild, voiceChannel, musicManager, selected, channel);
                                command.sendTranslatedMessage("Adding {0} to the queue".replace("{0}", selected.getInfo().title) + " " + getDuration(selected), channel, user);
                            } catch (Exception e) {
                                command.sendTranslatedMessage("Invalid response", channel, user);
                            }
                        });
                    } else {
                        AudioTrack track = playlist.getTracks().get(0);
                        play(user, guild, voiceChannel, musicManager, track, channel);
                        command.sendTranslatedMessage("Adding {0} to the queue".replace("{0}", track.getInfo().title) + " " + getDuration(track), channel, user);
                    }
                } catch (Exception e) {
                    new BotException(e);
                }
            } else {
                if (!UserUtils.hasTierTwoPermissions(user) && !EntityGuild.get(guild).isPremium()) {
                    try {
                        if (!shouldContinue(user, guild, channel, 1)) {
                            return;
                        }
                    } catch (Exception e) {
                        new BotException(e);
                    }
                }
                try {
                    command.sendTranslatedMessage("Adding {0} songs to the queue".replace("{0}", String.valueOf(tracks.size())), channel, user);
                } catch (Exception e) {
                    new BotException(e);
                }
                for (AudioTrack track : tracks) {
                    play(user, guild, voiceChannel, musicManager, track, channel);
                }
            }
        }

        @Override
        public void noMatches() {
            if (!search) {
                loadAndPlay(message, user, command, channel, "ytsearch: " + finalTrackUrl, voiceChannel, true, useEmbedSelect);
            } else {
                try {
                    command.sendTranslatedMessage("I couldn't find a song with that name", channel, user);
                } catch (Exception e) {
                    new BotException(e);
                }
            }
        }

        @Override
        public void loadFailed(FriendlyException exception) {
            try {
                sendTo(channel, guild).sendMessage("I wasn't able to play that track... **Reason: **" + exception.getLocalizedMessage()).queue();
            } catch (Exception e) {
                new BotException(e);
            }
        }
    });
}
Also used : AudioLoadResultHandler(com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler) AudioPlayer(com.sedmelluq.discord.lavaplayer.player.AudioPlayer) TrackRequest(com.wrapper.spotify.methods.TrackRequest) MessageUtils(tk.ardentbot.utils.discord.MessageUtils) MusicSettingsModel(tk.ardentbot.rethink.models.MusicSettingsModel) Database.r(tk.ardentbot.rethink.Database.r) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist) ArrayList(java.util.ArrayList) EntityGuild(tk.ardentbot.utils.rpg.EntityGuild) PermissionException(net.dv8tion.jda.core.exceptions.PermissionException) GuildUtils(tk.ardentbot.utils.discord.GuildUtils) SQLException(java.sql.SQLException) Permission(net.dv8tion.jda.core.Permission) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) Region(net.dv8tion.jda.core.Region) ShardManager(tk.ardentbot.main.ShardManager) Command(tk.ardentbot.core.executor.Command) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) UserUtils(tk.ardentbot.utils.discord.UserUtils) Subcommand(tk.ardentbot.core.executor.Subcommand) AudioManager(net.dv8tion.jda.core.managers.AudioManager) BaseCommand(tk.ardentbot.core.executor.BaseCommand) BotException(tk.ardentbot.core.misc.logging.BotException) Shard(tk.ardentbot.main.Shard) AudioLoadResultHandler(com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Ardent.spotifyApi(tk.ardentbot.main.Ardent.spotifyApi) Database.connection(tk.ardentbot.rethink.Database.connection) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) Pair(tk.ardentbot.utils.javaAdditions.Pair) WordUtils(org.apache.commons.lang.WordUtils) ArrayList(java.util.ArrayList) EntityGuild(tk.ardentbot.utils.rpg.EntityGuild) PermissionException(net.dv8tion.jda.core.exceptions.PermissionException) SQLException(java.sql.SQLException) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) BotException(tk.ardentbot.core.misc.logging.BotException) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) TrackRequest(com.wrapper.spotify.methods.TrackRequest) BotException(tk.ardentbot.core.misc.logging.BotException) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) ArrayList(java.util.ArrayList) List(java.util.List) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)

Example 3 with Command

use of tk.ardentbot.core.executor.Command in project Ardent by adamint.

the class Trivia method setupSubcommands.

@Override
public void setupSubcommands() throws Exception {
    subcommands.add(new Subcommand("Start a new trivia game", "start", "start") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            for (TriviaGame triviaGame : gamesInSession) {
                if (triviaGame.getGuildId().equalsIgnoreCase(guild.getId())) {
                    sendTranslatedMessage("There's already a game in session in this server!", channel, user);
                    return;
                }
            }
            if (gamesSettingUp.contains(guild.getId())) {
                sendTranslatedMessage("There's already a game in session in this server!", channel, user);
                return;
            }
            gamesSettingUp.add(guild.getId());
            sendTranslatedMessage("Do you want to play this solo? Type `yes` if so, or `no` if not", channel, user);
            interactiveOperation(channel, message, (soloMessage) -> {
                String content = soloMessage.getContent();
                boolean solo;
                solo = content.equalsIgnoreCase("yes");
                TriviaGame currentGame = new TriviaGame(user, solo, (TextChannel) channel, 15);
                gamesInSession.add(currentGame);
                sendTranslatedMessage("The game is starting! Type your answers in this channel. You have **15** seconds to answer " + "each question.", channel, user);
                commenceRounds(guild, (TextChannel) channel, user, currentGame);
                gamesSettingUp.remove(guild.getId());
            });
        }
    });
    subcommands.add(new Subcommand("Stop a currently active trivia game", "stop", "stop") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            if (guild.getMember(user).hasPermission(Permission.MANAGE_SERVER)) {
                if (gamesInSession.stream().filter(game -> game.getGuildId().equals(guild.getId())).count() > 0 || gamesSettingUp.contains(guild.getId())) {
                    gamesSettingUp.remove(guild.getId());
                    gamesInSession.removeIf(g -> g.getGuildId().equals(guild.getId()));
                    sendTranslatedMessage("Stopped the trivia game in session.", channel, user);
                } else {
                    sendTranslatedMessage("There isn't a trivia game running!", channel, user);
                }
            } else
                sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
        }
    });
}
Also used : Command(tk.ardentbot.core.executor.Command) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) Subcommand(tk.ardentbot.core.executor.Subcommand) BotException(tk.ardentbot.core.misc.logging.BotException) Shard(tk.ardentbot.main.Shard) TriviaQuestion(tk.ardentbot.utils.models.TriviaQuestion) Executors(java.util.concurrent.Executors) ArrayList(java.util.ArrayList) SecureRandom(java.security.SecureRandom) TimeUnit(java.util.concurrent.TimeUnit) GuildUtils(tk.ardentbot.utils.discord.GuildUtils) Permission(net.dv8tion.jda.core.Permission) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TriviaGame(tk.ardentbot.utils.rpg.TriviaGame) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Subcommand(tk.ardentbot.core.executor.Subcommand) TriviaGame(tk.ardentbot.utils.rpg.TriviaGame) BotException(tk.ardentbot.core.misc.logging.BotException)

Example 4 with Command

use of tk.ardentbot.core.executor.Command in project Ardent by adamint.

the class Admin method update.

public static void update(Command command, MessageChannel channel) throws Exception {
    channel.sendMessage("Updating now!").queue();
    for (Shard shard : getShards()) {
        for (Guild g : shard.jda.getGuilds()) {
            if (g.getAudioManager().isConnected()) {
                GuildMusicManager manager = Music.getGuildAudioPlayer(g, null);
                TextChannel ch = manager.scheduler.manager.getChannel();
                if (ch == null) {
                    g.getPublicChannel().sendMessage("I'm restarting in **5** minutes for updates!").queue();
                } else {
                    ch.sendMessage("I'm restarting in **5** minutes for updates!").queue();
                }
            }
        }
        shard.executorService.schedule(() -> {
            shard.jda.getGuilds().stream().filter(g -> g.getAudioManager().isConnected()).forEach(g -> {
                GuildMusicManager manager = Music.getGuildAudioPlayer(g, null);
                TextChannel ch = manager.scheduler.manager.getChannel();
                if (ch == null) {
                    g.getPublicChannel().sendMessage("Updating, I'll be online in a minute!").queue();
                } else {
                    ch.sendMessage("Updating, I'll be online in a minute!").queue();
                }
            });
            shutdown();
        }, 4, TimeUnit.MINUTES);
    }
}
Also used : GuildMusicManager(tk.ardentbot.commands.music.GuildMusicManager) Command(tk.ardentbot.core.executor.Command) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) Staff(tk.ardentbot.rethink.models.Staff) Database.r(tk.ardentbot.rethink.Database.r) Profile(tk.ardentbot.utils.rpg.profiles.Profile) BotException(tk.ardentbot.core.misc.logging.BotException) Shard(tk.ardentbot.main.Shard) Executors(java.util.concurrent.Executors) UsageUtils(tk.ardentbot.utils.discord.UsageUtils) TimeUnit(java.util.concurrent.TimeUnit) GuildUtils(tk.ardentbot.utils.discord.GuildUtils) List(java.util.List) ShardManager.getShards(tk.ardentbot.main.ShardManager.getShards) Music(tk.ardentbot.commands.music.Music) Database.connection(tk.ardentbot.rethink.Database.connection) Map(java.util.Map) InternalStats(tk.ardentbot.utils.discord.InternalStats) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Ardent(tk.ardentbot.main.Ardent) GuildMusicManager(tk.ardentbot.commands.music.GuildMusicManager) Shard(tk.ardentbot.main.Shard)

Example 5 with Command

use of tk.ardentbot.core.executor.Command in project Ardent by adamint.

the class Iam method setupSubcommands.

@Override
public void setupSubcommands() throws Exception {
    subcommands.add(new Subcommand("See a list of setup Iams", "view", "view") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            Shard shard = GuildUtils.getShard(guild);
            String title = "Auto Roles | /iam";
            String givesYouRole = "will give you the role";
            EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
            builder.setAuthor(title, shard.url, shard.bot.getAvatarUrl());
            StringBuilder msg = new StringBuilder();
            msg.append("**" + title + "**");
            for (Pair<String, Role> autorole : getAutoRoles(guild)) {
                String roleName;
                Role role = autorole.getV();
                if (role == null)
                    roleName = "deleted-role";
                else
                    roleName = role.getName();
                msg.append("\n**" + autorole.getK() + "** " + givesYouRole + " **" + roleName + "**");
            }
            msg.append("\n\nAdd an autorole by doing /iam role and going through the setup wizard");
            builder.setDescription(msg.toString());
            sendEmbed(builder, channel, user);
        }
    });
    subcommands.add(new Subcommand("Give yourself an autorole", "role", "role") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            if (args.length > 2) {
                String query = message.getRawContent().replace(GuildUtils.getPrefix(guild) + args[0] + " " + args[1] + " ", "");
                boolean found = false;
                ArrayList<Pair<String, Role>> autoroles = getAutoRoles(guild);
                for (Pair<String, Role> rolePair : autoroles) {
                    if (rolePair.getK().equalsIgnoreCase(query)) {
                        found = true;
                        Role role = rolePair.getV();
                        if (role == null)
                            sendTranslatedMessage("Hmm.. there's no role for this", channel, user);
                        else {
                            boolean failure = false;
                            try {
                                guild.getController().addRolesToMember(guild.getMember(user), role).queue();
                            } catch (Exception ex) {
                                failure = true;
                                sendTranslatedMessage("Please make sure I can add roles", channel, user);
                            }
                            if (!failure)
                                sendTranslatedMessage("Successfully gave you the role {0}".replace("{0}", role.getName()), channel, user);
                        }
                    }
                }
                if (!found)
                    sendTranslatedMessage("An autorole with that name wasn't found", channel, user);
            } else
                sendTranslatedMessage("You need to include an autorole name", channel, user);
        }
    });
    subcommands.add(new Subcommand("Remove autoroles", "remove", "remove") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            if (UserUtils.hasManageServerOrStaff(guild.getMember(user))) {
                String query = message.getRawContent().replace(GuildUtils.getPrefix(guild) + args[0] + " " + args[1] + " ", "");
                boolean found = false;
                ArrayList<Pair<String, Role>> autoroles = getAutoRoles(guild);
                for (Pair<String, Role> rolePair : autoroles) {
                    if (rolePair.getK().equalsIgnoreCase(query)) {
                        found = true;
                        r.db("data").table("autoroles").filter(row -> row.g("name").eq(query).and(row.g("guild_id").eq(guild.getId()))).delete().run(connection);
                        sendTranslatedMessage("Deleted the autorole **{0}**".replace("{0}", rolePair.getK()), channel, user);
                    }
                }
                if (!found)
                    sendTranslatedMessage("An autorole with that name wasn't found", channel, user);
            } else
                sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
        }
    });
    subcommands.add(new Subcommand("Add an autorole", "add", "add") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) {
            if (UserUtils.hasManageServerOrStaff(guild.getMember(user))) {
                sendTranslatedMessage("Type the name of the autorole you want to add", channel, user);
                interactiveOperation(channel, message, nameMessage -> {
                    String name = nameMessage.getContent();
                    sendTranslatedMessage("Type the name of the **discord role** you want this set to", channel, user);
                    interactiveOperation(channel, message, roleMessage -> {
                        try {
                            String role = roleMessage.getRawContent();
                            boolean found = false;
                            ArrayList<Pair<String, Role>> autoroles = getAutoRoles(guild);
                            for (Pair<String, Role> rolePair : autoroles) {
                                if (rolePair.getK().equalsIgnoreCase(name)) {
                                    found = true;
                                }
                            }
                            if (found)
                                sendTranslatedMessage("An autorole with that name is already setup", channel, user);
                            else {
                                List<Role> roleList = guild.getRolesByName(role, true);
                                if (roleList.size() > 0) {
                                    Role toAdd = roleList.get(0);
                                    r.table("autoroles").insert(r.json(gson.toJson(new AutoroleModel(guild.getId(), name, toAdd.getId())))).run(connection);
                                    sendTranslatedMessage("Successfully added autorole **{0}** which gives the role **{1}**".replace("{0}", name).replace("{1}", role), channel, user);
                                } else
                                    sendTranslatedMessage("An role with that name wasn't found", channel, user);
                            }
                        } catch (Exception e) {
                            new BotException(e);
                        }
                    });
                });
            } else
                sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
        }
    });
}
Also used : MessageUtils(tk.ardentbot.utils.discord.MessageUtils) Command(tk.ardentbot.core.executor.Command) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) UserUtils(tk.ardentbot.utils.discord.UserUtils) Subcommand(tk.ardentbot.core.executor.Subcommand) Database.r(tk.ardentbot.rethink.Database.r) HashMap(java.util.HashMap) BotException(tk.ardentbot.core.misc.logging.BotException) Shard(tk.ardentbot.main.Shard) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) ArrayList(java.util.ArrayList) GuildUtils(tk.ardentbot.utils.discord.GuildUtils) List(java.util.List) Cursor(com.rethinkdb.net.Cursor) Database.connection(tk.ardentbot.rethink.Database.connection) AutoroleModel(tk.ardentbot.rethink.models.AutoroleModel) Pair(tk.ardentbot.utils.javaAdditions.Pair) Subcommand(tk.ardentbot.core.executor.Subcommand) ArrayList(java.util.ArrayList) BotException(tk.ardentbot.core.misc.logging.BotException) AutoroleModel(tk.ardentbot.rethink.models.AutoroleModel) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) BotException(tk.ardentbot.core.misc.logging.BotException) ArrayList(java.util.ArrayList) List(java.util.List) Shard(tk.ardentbot.main.Shard) Pair(tk.ardentbot.utils.javaAdditions.Pair)

Aggregations

Command (tk.ardentbot.core.executor.Command)7 net.dv8tion.jda.core.entities (net.dv8tion.jda.core.entities)6 Subcommand (tk.ardentbot.core.executor.Subcommand)6 List (java.util.List)5 BotException (tk.ardentbot.core.misc.logging.BotException)5 Shard (tk.ardentbot.main.Shard)5 Database.connection (tk.ardentbot.rethink.Database.connection)5 Database.r (tk.ardentbot.rethink.Database.r)5 ArrayList (java.util.ArrayList)4 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)4 Permission (net.dv8tion.jda.core.Permission)4 GuildUtils (tk.ardentbot.utils.discord.GuildUtils)4 MessageUtils (tk.ardentbot.utils.discord.MessageUtils)4 HashMap (java.util.HashMap)3 TimeUnit (java.util.concurrent.TimeUnit)3 Cursor (com.rethinkdb.net.Cursor)2 Map (java.util.Map)2 Executors (java.util.concurrent.Executors)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 ShardManager (tk.ardentbot.main.ShardManager)2