Search in sources :

Example 1 with Permission

use of github.scarsz.discordsrv.dependencies.jda.api.Permission in project InteractiveChat-DiscordSRV-Addon by LOOHP.

the class DiscordReadyEvents method ready.

public void ready() {
    Debug.debug("Triggering discord ready...");
    DiscordSRV discordsrv = InteractiveChatDiscordSrvAddon.discordsrv;
    JDA jda = discordsrv.getJda();
    jda.addEventListener(new OutboundToDiscordEvents.JDAEvents());
    DiscordCommands discordCommands = new DiscordCommands(discordsrv);
    jda.addEventListener(discordCommands);
    Bukkit.getPluginManager().registerEvents(discordCommands, InteractiveChatDiscordSrvAddon.plugin);
    for (String channelId : discordsrv.getChannels().values()) {
        if (channelId != null) {
            try {
                GuildChannel channel = jda.getGuildChannelById(channelId);
                if (channel != null) {
                    Guild guild = channel.getGuild();
                    Member self = guild.getMember(jda.getSelfUser());
                    for (Permission permission : InteractiveChatDiscordSrvAddon.requiredPermissions) {
                        if (!self.hasPermission(channel, permission)) {
                            Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[ICDiscordSrvAddon] DiscordSRV Bot is missing the \"" + permission.getName() + "\" permission in the channel \"" + channel.getName() + "\" (Id: " + channel.getId() + ")");
                        }
                    }
                }
            } catch (Exception e) {
                new RuntimeException("Error when getting guild from channelId (" + channelId + ")", e).printStackTrace();
            }
        }
    }
}
Also used : GuildChannel(github.scarsz.discordsrv.dependencies.jda.api.entities.GuildChannel) JDA(github.scarsz.discordsrv.dependencies.jda.api.JDA) Permission(github.scarsz.discordsrv.dependencies.jda.api.Permission) DiscordSRV(github.scarsz.discordsrv.DiscordSRV) Guild(github.scarsz.discordsrv.dependencies.jda.api.entities.Guild) Member(github.scarsz.discordsrv.dependencies.jda.api.entities.Member)

Aggregations

DiscordSRV (github.scarsz.discordsrv.DiscordSRV)1 JDA (github.scarsz.discordsrv.dependencies.jda.api.JDA)1 Permission (github.scarsz.discordsrv.dependencies.jda.api.Permission)1 Guild (github.scarsz.discordsrv.dependencies.jda.api.entities.Guild)1 GuildChannel (github.scarsz.discordsrv.dependencies.jda.api.entities.GuildChannel)1 Member (github.scarsz.discordsrv.dependencies.jda.api.entities.Member)1