use of com.gamebuster19901.excite.bot.database.sql.PreparedStatement in project ExciteBot by TheGameCommunity.
the class LogInAudit method addLoginAudit.
public static LogInAudit addLoginAudit(MessageContext context, Player player) {
Audit parent = Audit.addAudit(context, AuditType.LOG_IN_AUDIT, getMessage(player));
PreparedStatement st;
try {
st = Insertion.insertInto(Table.AUDIT_PROFILE_LOGINS).setColumns(AUDIT_ID).to(parent.getID()).prepare(context, true);
st.execute();
LogInAudit ret = getLoginAuditByAuditID(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 MailAudit method addMailAudit.
@SuppressWarnings("rawtypes")
public static MailAudit addMailAudit(MessageContext context, MailReplyResponse message, boolean incoming, File file) {
ElectronicAddress from = message.getResponder();
ElectronicAddress to = message.getRespondee();
String description = from.getEmail() + " sent mail to " + to.getEmail();
String mailType = "GENERIC";
if (message instanceof AddFriendResponse) {
description = from.getEmail() + " sent a friend request to " + to.getEmail();
mailType = "FRIEND_REQUEST";
} else if (message instanceof RefundResponse) {
description = "refunded " + ((RefundResponse) message).getReward() + " to " + to.getEmail();
mailType = "REFUND";
}
Audit parent = Audit.addAudit(context, AuditType.MAIL_AUDIT, description);
PreparedStatement st;
try {
st = Insertion.insertInto(Table.MAIL).setColumns(AUDIT_ID, SENDER, RECIPIENT, INCOMING, MAIL_TYPE, FILE).to(parent.getID(), from.getEmail(), to.getEmail(), incoming, mailType, file.getAbsolutePath()).prepare(context, true);
st.execute();
MailAudit ret = getMailAuditByAuditID(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 WiiRegistrationAudit method addWiiRegistrationAudit.
public static WiiRegistrationAudit addWiiRegistrationAudit(MessageContext registrant, Wii wii, boolean unregister) {
Audit parent;
if (!unregister) {
parent = Audit.addAudit(registrant, AuditType.WII_REGISTRATION_AUDIT, registrant.getAuthor().getIdentifierName() + " registered " + wii.getWiiCode().hyphenate());
} else {
parent = Audit.addAudit(registrant, AuditType.WII_REGISTRATION_AUDIT, registrant.getAuthor().getIdentifierName() + " unregistered " + wii.getWiiCode().hyphenate());
}
PreparedStatement st;
try {
st = Insertion.insertInto(Table.AUDIT_WII_REGISTER).setColumns(AUDIT_ID, WII_ID, DISCORD_ID, UNREGISTER).to(parent.getID(), wii.getWiiCode().toString(), registrant.getSenderId(), unregister).prepare(true);
st.execute();
WiiRegistrationAudit ret = getWiiRegistrationAuditByID(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 DiscordUser method getAllAdmins.
public static DiscordUser[] getAllAdmins() {
try {
PreparedStatement st = ConsoleContext.INSTANCE.getConnection().prepareStatement("SELECT * FROM discord_users INNER JOIN admins ON(discord_users.discordID = admins.discordID);");
Result results = st.query();
int columns = results.getColumnCount();
DiscordUser[] operators = new DiscordUser[columns];
for (int i = 0; i < columns; i++) {
results.next();
operators[i] = new DiscordUser(results);
}
return operators;
} catch (SQLException e) {
throw new AssertionError(e);
}
}
use of com.gamebuster19901.excite.bot.database.sql.PreparedStatement in project ExciteBot by TheGameCommunity.
the class DiscordServer method addServer.
@SuppressWarnings({ "rawtypes", "resource" })
public static DiscordServer addServer(MessageContext context, long guildId, String name) throws SQLException {
PreparedStatement ps = context.getConnection().prepareStatement("INSERT INTO " + DISCORD_SERVERS + " (" + SERVER_ID + ", " + SERVER_NAME + ") VALUES (?, ?)");
ps.setLong(1, guildId);
ps.setString(2, name);
ps.execute();
return getServer(context, guildId);
}
Aggregations