Search in sources :

Example 1 with Banee

use of com.gamebuster19901.excite.bot.audit.ban.Banee in project ExciteBot by TheGameCommunity.

the class PardonCommand method pardon.

@SuppressWarnings("rawtypes")
private static final int pardon(MessageContext context, long baneeOrBanID) {
    if (context.isAdmin()) {
        Ban ban = Ban.getBanByAuditId(context, baneeOrBanID);
        if (ban != null) {
            return pardon(context, ban);
        }
        Banee banee = Banee.getBanee(context, baneeOrBanID);
        return pardon(context, banee);
    } else {
        context.sendMessage("You do not have permission to execute this command");
    }
    return 1;
}
Also used : Banee(com.gamebuster19901.excite.bot.audit.ban.Banee) Ban(com.gamebuster19901.excite.bot.audit.ban.Ban)

Example 2 with Banee

use of com.gamebuster19901.excite.bot.audit.ban.Banee in project ExciteBot by TheGameCommunity.

the class Ban method addBan.

@SuppressWarnings({ "rawtypes", "deprecation" })
public static Ban addBan(MessageContext context, Banee banee, String reason, Duration banDuration, Instant banExpire, long pardon) {
    Audit parent = Audit.addAudit(context, AuditType.BAN, reason);
    PreparedStatement st;
    context.sendMessage(banee.getClass().getCanonicalName());
    try {
        st = Insertion.insertInto(AUDIT_BANS).setColumns(AUDIT_ID, BAN_DURATION, BAN_EXPIRE, BANNED_ID, BANNED_USERNAME).to(parent.getID(), banDuration, banExpire, banee.getID(), banee.getName()).prepare(context, true);
        st.execute();
        Ban ret = getBanByAuditId(context, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : Audit(com.gamebuster19901.excite.bot.audit.Audit) SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 3 with Banee

use of com.gamebuster19901.excite.bot.audit.ban.Banee in project ExciteBot by TheGameCommunity.

the class Banee method getBanee.

@SuppressWarnings("rawtypes")
public static Banee getBanee(MessageContext context, long id) {
    DiscordUser discord = DiscordUser.getDiscordUserIncludingUnknown(context, id);
    Player player = Player.getPlayerByID(context, (int) id);
    if (!player.isKnown()) {
        return discord;
    }
    return player;
}
Also used : DiscordUser(com.gamebuster19901.excite.bot.user.DiscordUser) Player(com.gamebuster19901.excite.Player)

Example 4 with Banee

use of com.gamebuster19901.excite.bot.audit.ban.Banee in project ExciteBot by TheGameCommunity.

the class Banee method getBanee.

@Nullable
@SuppressWarnings({ "rawtypes", "deprecation" })
public static Banee getBanee(MessageContext context, String name) {
    DiscordUser[] discords = DiscordUser.getDiscordUsersWithUsername(context, name);
    Player[] players = Player.getPlayersByName(context, name);
    int amount = discords.length + players.length;
    if (amount == 1) {
        if (discords.length == 1) {
            return discords[0];
        }
        return players[0];
    } else if (amount < 1) {
        context.sendMessage("Could not find a discord user or player named " + name);
    } else if (amount > 1) {
        String ret = name + " is ambiguous, please supply an ID instead.\n\nAmbiguities\n\n:";
        if (discords.length > 0) {
            ret = ret + "Discord Users:\n";
            for (DiscordUser discord : discords) {
                ret = ret + discord.toDetailedString();
            }
        }
        if (players.length > 0) {
            ret = ret + "Profiles:\n";
            for (Player player : players) {
                ret = ret + player.toFullString();
            }
        }
        context.sendMessage(ret);
    }
    return null;
}
Also used : DiscordUser(com.gamebuster19901.excite.bot.user.DiscordUser) Player(com.gamebuster19901.excite.Player) Nullable(javax.annotation.Nullable)

Example 5 with Banee

use of com.gamebuster19901.excite.bot.audit.ban.Banee in project ExciteBot by TheGameCommunity.

the class PardonCommand method pardon.

@SuppressWarnings("rawtypes")
private static final int pardon(MessageContext context, Banee banee) {
    if (context.isAdmin()) {
        Ban ban = banee.getLongestActiveBan(context);
        if (ban == null) {
            context.sendMessage(banee.getIdentifierName() + " is not banned.");
            return 1;
        }
        Pardon pardon = Pardon.addPardonByAuditID(context, ban.getID());
        if (pardon != null) {
            context.sendMessage("pardoned the longest ban (#" + ban.getID() + ") of " + banee.getIdentifierName());
        }
    } else {
        context.sendMessage("You do not have permission to execute this command");
    }
    return 1;
}
Also used : Pardon(com.gamebuster19901.excite.bot.audit.ban.Pardon) Ban(com.gamebuster19901.excite.bot.audit.ban.Ban)

Aggregations

Player (com.gamebuster19901.excite.Player)2 Ban (com.gamebuster19901.excite.bot.audit.ban.Ban)2 DiscordUser (com.gamebuster19901.excite.bot.user.DiscordUser)2 Audit (com.gamebuster19901.excite.bot.audit.Audit)1 Banee (com.gamebuster19901.excite.bot.audit.ban.Banee)1 Pardon (com.gamebuster19901.excite.bot.audit.ban.Pardon)1 PreparedStatement (com.gamebuster19901.excite.bot.database.sql.PreparedStatement)1 IOError (java.io.IOError)1 SQLException (java.sql.SQLException)1 Nullable (javax.annotation.Nullable)1