Search in sources :

Example 6 with Ban

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

the class DiscordUser method ban.

@SuppressWarnings({ "rawtypes", "unchecked" })
public Ban ban(MessageContext context, Duration duration, String reason) {
    Ban discordBan = Ban.addBan(context, this, reason, duration);
    sendMessage(context, this.toDetailedString() + " has been banned for " + TimeUtils.readableDuration(duration) + " with the reason: \n\n\"" + reason + "\"");
    sendMessage(new MessageContext(this), this.getName() + " " + reason);
    return discordBan;
}
Also used : MessageContext(com.gamebuster19901.excite.bot.command.MessageContext) Ban(com.gamebuster19901.excite.bot.audit.ban.Ban)

Example 7 with Ban

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

the class BanCommand method banProfile.

@SuppressWarnings("rawtypes")
private static int banProfile(MessageContext context, Player profile, Duration duration, String reason) {
    if (context.isAdmin()) {
        Ban ban = profile.ban(context, duration, reason);
        String message = "Banned profile " + profile.getPrettyDiscord() + ": \n\n" + ban;
        if (context.isConsoleMessage()) {
            context.sendMessage(message);
        } else {
            PrivateChannel privateChannel;
            if (context.isPrivateMessage()) {
                privateChannel = (PrivateChannel) context.getChannel();
            } else {
                privateChannel = context.getDiscordAuthor().getJDAUser().openPrivateChannel().complete();
            }
            privateChannel.sendMessage(message);
        }
    } else {
        context.sendMessage("You do not have permission to execute this command");
    }
    return 1;
}
Also used : PrivateChannel(net.dv8tion.jda.api.entities.PrivateChannel) Ban(com.gamebuster19901.excite.bot.audit.ban.Ban)

Example 8 with Ban

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

the class BanCommand method banDiscordUser.

@SuppressWarnings("rawtypes")
private static int banDiscordUser(MessageContext context, DiscordUser user, Duration duration, String reason) {
    if (context.isAdmin()) {
        Ban ban = user.ban(context, duration, parseReason(duration, reason));
        String message = "Banned discord user" + user + ": \n\n" + ban;
        if (context.isConsoleMessage()) {
            context.sendMessage(message);
        } else {
            PrivateChannel privateChannel;
            if (context.isPrivateMessage()) {
                privateChannel = (PrivateChannel) context.getChannel();
            } else {
                privateChannel = context.getDiscordAuthor().getJDAUser().openPrivateChannel().complete();
            }
            privateChannel.sendMessage(message);
        }
    } else {
        context.sendMessage("You do not have permission to execute this command");
    }
    return 1;
}
Also used : PrivateChannel(net.dv8tion.jda.api.entities.PrivateChannel) Ban(com.gamebuster19901.excite.bot.audit.ban.Ban)

Example 9 with Ban

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

the class Ban method getBansOfID.

@SuppressWarnings("rawtypes")
public static Ban[] getBansOfID(MessageContext context, long id) {
    if (id == -1 || id == -2) {
        throw new AssertionError();
    }
    Result results = Table.selectAllFromJoinedUsingWhere(new MessageContext(context.getAuthor()), AUDITS, AUDIT_BANS, AUDIT_ID, new Comparison(BANNED_ID, EQUALS, id));
    ArrayList<Ban> bans = new ArrayList<Ban>();
    while (results.next()) {
        bans.add(new Ban(results.getRow()));
    }
    return bans.toArray(new Ban[] {});
}
Also used : Comparison(com.gamebuster19901.excite.bot.database.Comparison) ArrayList(java.util.ArrayList) MessageContext(com.gamebuster19901.excite.bot.command.MessageContext) Result(com.gamebuster19901.excite.bot.database.Result)

Example 10 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, 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

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