Search in sources :

Example 1 with Ban

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

the class Player method ban.

@SuppressWarnings({ "rawtypes" })
public Ban ban(MessageContext context, Duration duration, String reason) {
    Ban ban = Ban.addBan(context, this, reason, duration);
    DiscordUser discord = DiscordUser.getDiscordUserIncludingUnknown(context, getDiscord());
    if (!(discord instanceof UnknownDiscordUser)) {
        discord.sendMessage(context, toString() + " " + reason);
    }
    return ban;
}
Also used : DiscordUser(com.gamebuster19901.excite.bot.user.DiscordUser) UnknownDiscordUser(com.gamebuster19901.excite.bot.user.UnknownDiscordUser) UnknownDiscordUser(com.gamebuster19901.excite.bot.user.UnknownDiscordUser) Ban(com.gamebuster19901.excite.bot.audit.ban.Ban)

Example 2 with Ban

use of com.gamebuster19901.excite.bot.audit.ban.Ban 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 3 with Ban

use of com.gamebuster19901.excite.bot.audit.ban.Ban 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 4 with Ban

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

the class Pardon method addPardonByAuditID.

@Nullable
@SuppressWarnings("rawtypes")
public static Pardon addPardonByAuditID(MessageContext context, long id) {
    try {
        Audit pardoned = Audit.getAuditById(context, id);
        if (pardoned == null) {
            context.sendMessage("Could not find audit #" + id);
            return null;
        }
        AuditType type = pardoned.getType();
        if (type == BAN) {
            Ban ban = (Ban) pardoned;
            if (ban.isPardoned()) {
                context.sendMessage(type + " #" + id + " is already pardoned.");
                return null;
            }
            Audit parent = Audit.addAudit(context, PARDON, context.getAuthor().getIdentifierName() + " pardoned " + ban.getBannedUsername());
            PreparedStatement st;
            st = Insertion.insertInto(AUDIT_PARDONS).setColumns(AUDIT_ID, PARDONED_AUDIT_ID).to(parent.getID(), pardoned.getID()).prepare(context, true);
            st.execute();
            Pardon ret = getPardonByAuditID(context, parent.getID());
            ret.parentData = parent;
            return ret;
        } else {
            context.sendMessage("Audit #" + id + " is a " + type + ", not a " + BAN);
            return null;
        }
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : Audit(com.gamebuster19901.excite.bot.audit.Audit) AuditType(com.gamebuster19901.excite.bot.audit.AuditType) SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement) Nullable(javax.annotation.Nullable)

Example 5 with Ban

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

the class BanCommand method banProfileForever.

@SuppressWarnings("rawtypes")
private static int banProfileForever(MessageContext context, Player[] profile, String reason) {
    if (profile.length != 1) {
        context.sendMessage("Ambigious name, enter a PID or FC");
        return 0;
    }
    if (context.isAdmin()) {
        if (profile[0] instanceof UnknownPlayer) {
            context.sendMessage("There is no profile known as " + profile);
            return 0;
        }
        Duration duration = ChronoUnit.FOREVER.getDuration();
        profile[0].ban(context, duration, parseReason(duration, reason));
    } else {
        context.sendMessage("You do not have permission to execute this command");
    }
    return 0;
}
Also used : Duration(java.time.Duration) UnknownPlayer(com.gamebuster19901.excite.UnknownPlayer)

Aggregations

Ban (com.gamebuster19901.excite.bot.audit.ban.Ban)6 Audit (com.gamebuster19901.excite.bot.audit.Audit)2 MessageContext (com.gamebuster19901.excite.bot.command.MessageContext)2 PreparedStatement (com.gamebuster19901.excite.bot.database.sql.PreparedStatement)2 IOError (java.io.IOError)2 SQLException (java.sql.SQLException)2 PrivateChannel (net.dv8tion.jda.api.entities.PrivateChannel)2 UnknownPlayer (com.gamebuster19901.excite.UnknownPlayer)1 AuditType (com.gamebuster19901.excite.bot.audit.AuditType)1 Banee (com.gamebuster19901.excite.bot.audit.ban.Banee)1 Pardon (com.gamebuster19901.excite.bot.audit.ban.Pardon)1 Comparison (com.gamebuster19901.excite.bot.database.Comparison)1 Result (com.gamebuster19901.excite.bot.database.Result)1 DiscordUser (com.gamebuster19901.excite.bot.user.DiscordUser)1 UnknownDiscordUser (com.gamebuster19901.excite.bot.user.UnknownDiscordUser)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1