Search in sources :

Example 1 with PreparedStatement

use of com.gamebuster19901.excite.bot.database.sql.PreparedStatement in project ExciteBot by TheGameCommunity.

the class Player method addPlayer.

@SuppressWarnings({ "rawtypes", "unchecked" })
public static Player addPlayer(MessageContext context, boolean automatic, int playerID, String friendCode, String name) throws SQLException {
    if (context.getEvent() instanceof UnknownPlayer) {
        UnknownPlayer player = (UnknownPlayer) context.getEvent();
        player.name = name;
        player.friendCode = friendCode;
    }
    PreparedStatement ps = Insertion.insertInto(PLAYERS).setColumns(PLAYER_ID, FRIEND_CODE, PLAYER_NAME).to(playerID, friendCode, name).prepare(ConsoleContext.INSTANCE);
    ps.execute();
    Player ret = getPlayerByID(context, playerID);
    DiscoveryAudit.addProfileDiscovery(context, automatic, ret);
    return ret;
}
Also used : PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 2 with PreparedStatement

use of com.gamebuster19901.excite.bot.database.sql.PreparedStatement in project ExciteBot by TheGameCommunity.

the class BotDeleteMessageAudit method addBotDeleteMessageAudit.

public static BotDeleteMessageAudit addBotDeleteMessageAudit(MessageContext deleter, MessageContext deleted, String reason) {
    Audit parent = Audit.addAudit(deleter, deleted, AuditType.BOT_MSG_DELETE, getMessage(ConsoleContext.INSTANCE, deleted, reason));
    PreparedStatement st;
    try {
        st = Insertion.insertInto(Table.AUDIT_BOT_MSG_DEL).setColumns(AUDIT_ID, DISCORD_ID).to(parent.getID(), deleted.getSenderId()).prepare(deleter, true);
        st.execute();
        BotDeleteMessageAudit ret = getBotDeleteMessageAuditByID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 3 with PreparedStatement

use of com.gamebuster19901.excite.bot.database.sql.PreparedStatement in project ExciteBot by TheGameCommunity.

the class LogOutAudit method addLogOutAudit.

public static LogOutAudit addLogOutAudit(MessageContext context, Player player) {
    Audit parent = Audit.addAudit(context, AuditType.LOG_OUT_AUDIT, getMessage(player));
    PreparedStatement st;
    try {
        st = Insertion.insertInto(Table.AUDIT_PROFILE_LOGOUTS).setColumns(AUDIT_ID).to(parent.getID()).prepare(context, true);
        st.execute();
        LogOutAudit ret = getLogOutAuditByAuditID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 4 with PreparedStatement

use of com.gamebuster19901.excite.bot.database.sql.PreparedStatement 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 5 with PreparedStatement

use of com.gamebuster19901.excite.bot.database.sql.PreparedStatement 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)

Aggregations

PreparedStatement (com.gamebuster19901.excite.bot.database.sql.PreparedStatement)19 SQLException (java.sql.SQLException)17 IOError (java.io.IOError)15 Audit (com.gamebuster19901.excite.bot.audit.Audit)2 Result (com.gamebuster19901.excite.bot.database.Result)2 ElectronicAddress (com.gamebuster19901.excite.bot.mail.ElectronicAddress)2 AuditType (com.gamebuster19901.excite.bot.audit.AuditType)1 MessageContext (com.gamebuster19901.excite.bot.command.MessageContext)1 Comparison (com.gamebuster19901.excite.bot.database.Comparison)1 Row (com.gamebuster19901.excite.bot.database.Row)1 ResultSet (com.gamebuster19901.excite.bot.database.sql.ResultSet)1 AddFriendResponse (com.gamebuster19901.excite.bot.mail.AddFriendResponse)1 EmailAddress (com.gamebuster19901.excite.bot.mail.EmailAddress)1 RefundResponse (com.gamebuster19901.excite.bot.mail.RefundResponse)1 Nullable (javax.annotation.Nullable)1 InternetAddress (javax.mail.internet.InternetAddress)1 ErrorResponseException (net.dv8tion.jda.api.exceptions.ErrorResponseException)1