Search in sources :

Example 1 with MissingPermissionDiscordException

use of exceptions.MissingPermissionDiscordException in project KaellyBot by Kaysoro.

the class Message method sendText.

public static void sendText(IChannel channel, String content) {
    Language lg = Translator.getLanguageFrom(channel);
    RequestBuffer.request(() -> {
        try {
            new MessageBuilder(ClientConfig.DISCORD()).withChannel(channel).withContent(content).build();
        } catch (RateLimitException e) {
            LoggerFactory.getLogger(Message.class).warn(e.getMessage(), e);
            throw e;
        } catch (DiscordException e) {
            Reporter.report(e, channel.isPrivate() ? null : channel.getGuild(), channel);
            LoggerFactory.getLogger(Message.class).error(e.getMessage(), e);
        } catch (MissingPermissionsException e) {
            LoggerFactory.getLogger(Message.class).warn(Constants.name + " n'a pas les permissions pour appliquer cette requête.");
            new MissingPermissionDiscordException().throwException(channel, lg, e);
        } catch (Exception e) {
            Reporter.report(e, channel.isPrivate() ? null : channel.getGuild(), channel);
            LoggerFactory.getLogger(Message.class).error(e.getMessage(), e);
        }
        return null;
    });
}
Also used : MissingPermissionDiscordException(exceptions.MissingPermissionDiscordException) Language(enums.Language) MissingPermissionDiscordException(exceptions.MissingPermissionDiscordException) MissingPermissionDiscordException(exceptions.MissingPermissionDiscordException)

Example 2 with MissingPermissionDiscordException

use of exceptions.MissingPermissionDiscordException in project KaellyBot by Kaysoro.

the class Message method sendEmbed.

public static void sendEmbed(IChannel channel, EmbedObject content) {
    Language lg = Translator.getLanguageFrom(channel);
    RequestBuffer.request(() -> {
        try {
            new MessageBuilder(ClientConfig.DISCORD()).withChannel(channel).withEmbed(content).build();
        } catch (RateLimitException e) {
            LoggerFactory.getLogger(Message.class).warn(e.getMessage(), e);
            throw e;
        } catch (DiscordException e) {
            Reporter.report(e, channel.isPrivate() ? null : channel.getGuild(), channel);
            LoggerFactory.getLogger(Message.class).error(e.getMessage(), e);
        } catch (MissingPermissionsException e) {
            LoggerFactory.getLogger(Message.class).warn(Constants.name + " n'a pas les permissions pour appliquer cette requête.");
            new MissingPermissionDiscordException().throwException(channel, lg, e);
        } catch (Exception e) {
            Reporter.report(e, channel.isPrivate() ? null : channel.getGuild(), channel);
            LoggerFactory.getLogger(Message.class).error(e.getMessage(), e);
        }
        return null;
    });
}
Also used : MissingPermissionDiscordException(exceptions.MissingPermissionDiscordException) Language(enums.Language) MissingPermissionDiscordException(exceptions.MissingPermissionDiscordException) MissingPermissionDiscordException(exceptions.MissingPermissionDiscordException)

Aggregations

Language (enums.Language)2 MissingPermissionDiscordException (exceptions.MissingPermissionDiscordException)2