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;
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations