Search in sources :

Example 1 with RSSCommand

use of commands.config.RSSCommand in project KaellyBot by Kaysoro.

the class GuildCreateListener method onReady.

@EventSubscriber
public void onReady(GuildCreateEvent event) {
    try {
        if (!Guild.getGuilds().containsKey(event.getGuild().getStringID())) {
            Guild guild = new Guild(event.getGuild().getStringID(), event.getGuild().getName(), Translator.detectLanguage(event.getGuild().getDefaultChannel()));
            guild.addToDatabase();
            Language lg = guild.getLanguage();
            LOG.info("La guilde " + guild.getId() + " - " + guild.getName() + " a ajouté " + Constants.name);
            String customMessage = Translator.getLabel(lg, "welcome.message");
            customMessage = customMessage.replaceAll("\\{name\\}", Constants.name).replaceAll("\\{game\\}", Constants.game).replaceAll("\\{prefix\\}", Constants.prefixCommand).replaceAll("\\{help\\}", HelpCommand.NAME).replaceAll("\\{server\\}", new ServerCommand().getName()).replaceAll("\\{lang\\}", new LanguageCommand().getName()).replaceAll("\\{twitter\\}", new TwitterCommand().getName()).replaceAll("\\{almanax\\}", new AlmanaxCommand().getName()).replaceAll("\\{rss\\}", new RSSCommand().getName()).replaceAll("\\{owner\\}", event.getGuild().getOwner().mention()).replaceAll("\\{guild\\}", event.getGuild().getName());
            if (event.getGuild().getDefaultChannel() != null && event.getGuild().getDefaultChannel().getModifiedPermissions(ClientConfig.DISCORD().getOurUser()).contains(Permissions.SEND_MESSAGES))
                Message.sendText(event.getGuild().getDefaultChannel(), customMessage);
            else
                try {
                    Message.sendText(event.getGuild().getOwner().getOrCreatePMChannel(), customMessage);
                } catch (DiscordException e) {
                    LOG.warn("onReady", "Impossible de contacter l'administrateur de la guilde [" + guild.getName() + "].");
                }
            Message.sendText(ClientConfig.DISCORD().getChannelByID(Constants.chanReportID), "[NEW] **" + guild.getName() + "** (" + guild.getLanguage().getAbrev() + "), +" + event.getGuild().getUsers().size() + " utilisateurs");
        }
    } catch (Exception e) {
        Reporter.report(e, event.getGuild());
        LOG.error("onReady", e);
    }
}
Also used : Language(enums.Language) DiscordException(sx.blah.discord.util.DiscordException) LanguageCommand(commands.config.LanguageCommand) Guild(data.Guild) DiscordException(sx.blah.discord.util.DiscordException) ServerCommand(commands.config.ServerCommand) TwitterCommand(commands.config.TwitterCommand) AlmanaxCommand(commands.classic.AlmanaxCommand) RSSCommand(commands.config.RSSCommand) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

Aggregations

AlmanaxCommand (commands.classic.AlmanaxCommand)1 LanguageCommand (commands.config.LanguageCommand)1 RSSCommand (commands.config.RSSCommand)1 ServerCommand (commands.config.ServerCommand)1 TwitterCommand (commands.config.TwitterCommand)1 Guild (data.Guild)1 Language (enums.Language)1 EventSubscriber (sx.blah.discord.api.events.EventSubscriber)1 DiscordException (sx.blah.discord.util.DiscordException)1