Search in sources :

Example 1 with ServerLogSQL

use of fun.rubicon.sql.ServerLogSQL in project Rubicon by Rubicon-Bot.

the class BotJoinListener method onGuildJoin.

/**
 * Creates the new guild in the database
 *
 * @param event
 */
@Override
public void onGuildJoin(GuildJoinEvent event) {
    CommandMute.createMutedRoleIfNotExists(event.getGuild(), null);
    // post statistics to discordbots.org
    DBLUtil.postStats(false);
    try {
        Guild g = event.getGuild();
        if (!RubiconBot.getMySQL().ifGuildExits(event.getGuild())) {
            RubiconBot.getMySQL().createGuildServer(g);
            new ServerLogSQL(event.getGuild());
        }
    } catch (Exception ex) {
        Logger.error(ex);
    }
}
Also used : ServerLogSQL(fun.rubicon.sql.ServerLogSQL) Guild(net.dv8tion.jda.core.entities.Guild) IOException(java.io.IOException)

Example 2 with ServerLogSQL

use of fun.rubicon.sql.ServerLogSQL in project Rubicon by Rubicon-Bot.

the class ServerLogHandler method getLogChannel.

private static TextChannel getLogChannel(Guild guild) {
    String entry = new ServerLogSQL(guild).get("channel");
    if (entry == null)
        return null;
    if (entry.equals("0"))
        return null;
    TextChannel textChannel;
    try {
        textChannel = guild.getTextChannelById(entry);
        return textChannel;
    } catch (NullPointerException ignored) {
    // channel deleted or something
    }
    return null;
}
Also used : ServerLogSQL(fun.rubicon.sql.ServerLogSQL) TextChannel(net.dv8tion.jda.core.entities.TextChannel)

Example 3 with ServerLogSQL

use of fun.rubicon.sql.ServerLogSQL in project Rubicon by Rubicon-Bot.

the class CommandLog method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    this.parsedCommandInvocation = parsedCommandInvocation;
    this.args = parsedCommandInvocation.getArgs();
    this.serverLogSQL = new ServerLogSQL(parsedCommandInvocation.getMessage().getGuild());
    if (args.length == 0)
        return createHelpMessage();
    if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
        return EmbedUtil.message(generateList());
    } else if (args.length == 2) {
        switch(args[0]) {
            case "channel":
                if (parsedCommandInvocation.getMessage().getMentionedChannels().size() != 1)
                    return EmbedUtil.message(EmbedUtil.error("Error!", "You have to mention `one` channel."));
                serverLogSQL.set("channel", parsedCommandInvocation.getMessage().getMentionedChannels().get(0).getId());
                return EmbedUtil.message(EmbedUtil.success("Success!", "Successfully set logchannel to `" + parsedCommandInvocation.getMessage().getMentionedChannels().get(0).getName() + "`"));
            case "join":
                return EmbedUtil.message(handleEventUpdate(LogEventKeys.JOIN, args[1]));
            case "leave":
                return EmbedUtil.message(handleEventUpdate(LogEventKeys.LEAVE, args[1]));
            case "command":
                return EmbedUtil.message(handleEventUpdate(LogEventKeys.COMMAND, args[1]));
            case "ban":
                return EmbedUtil.message(handleEventUpdate(LogEventKeys.BAN, args[1]));
            case "role":
                return EmbedUtil.message(handleEventUpdate(LogEventKeys.ROLE, args[1]));
            case "voice":
                return EmbedUtil.message(handleEventUpdate(LogEventKeys.VOICE, args[1]));
        }
    }
    return createHelpMessage();
}
Also used : ServerLogSQL(fun.rubicon.sql.ServerLogSQL)

Aggregations

ServerLogSQL (fun.rubicon.sql.ServerLogSQL)3 IOException (java.io.IOException)1 Guild (net.dv8tion.jda.core.entities.Guild)1 TextChannel (net.dv8tion.jda.core.entities.TextChannel)1