Search in sources :

Example 1 with AirUtils

use of ml.duncte123.skybot.utils.AirUtils in project SkyBot by duncte123.

the class GuildSettingsUtils method loadGuildSettings.

/**
 * This will get the settings from our database and store them in the {@link AirUtils#guildSettings settings}
 */
private static void loadGuildSettings() {
    logger.debug("Loading Guild settings.");
    String dbName = AirUtils.DB.getName();
    Connection database = AirUtils.DB.getConnManager().getConnection();
    try {
        Statement smt = database.createStatement();
        ResultSet res = smt.executeQuery("SELECT * FROM " + dbName + ".guildSettings");
        while (res.next()) {
            String guildId = res.getString("guildId");
            AirUtils.guildSettings.put(guildId, new GuildSettings(guildId).setEnableJoinMessage(res.getBoolean("enableJoinMessage")).setEnableSwearFilter(res.getBoolean("enableSwearFilter")).setCustomJoinMessage(replaceNewLines(res.getString("customWelcomeMessage"))).setCustomPrefix(res.getString("prefix")).setLogChannel(res.getString("logChannelId")).setWelcomeLeaveChannel(res.getString("welcomeLeaveChannel")).setCustomLeaveMessage(replaceNewLines(res.getString("customLeaveMessage"))).setAutoroleRole(res.getString("autoRole")).setServerDesc(replaceNewLines(res.getString("serverDesc"))).setAnnounceTracks(res.getBoolean("announceNextTrack")).setAutoDeHoist(res.getBoolean("autoDeHoist")).setFilterInvites(res.getBoolean("filterInvites")));
        }
        logger.debug("Loaded settings for " + AirUtils.guildSettings.keySet().size() + " guilds.");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            database.close();
        } catch (SQLException e2) {
            e2.printStackTrace();
        }
    }
}
Also used : GuildSettings(ml.duncte123.skybot.objects.guild.GuildSettings)

Aggregations

GuildSettings (ml.duncte123.skybot.objects.guild.GuildSettings)1