use of com.gamebuster19901.excite.bot.database.Comparison in project ExciteBot by TheGameCommunity.
the class Wii method register.
public void register(MessageContext owner) throws SQLException, MessagingException {
Table.updateWhere(owner, WIIS, DISCORD_ID, owner.getSenderId(), new Comparison(WII_ID, EQUALS, wiiCode.code));
Table.updateWhere(owner, WIIS, REGISTRATION_CODE, null, new Comparison(WII_ID, EQUALS, wiiCode.code));
WiiRegistrationAudit.addWiiRegistrationAudit(owner, this, false);
EmbedBuilder embed = new EmbedBuilder();
embed.setColor(Color.GREEN);
embed.setTitle("Registration Successful");
embed.setDescription("You have succesfully registered the following wii:\n\n" + this.getIdentifierName());
ElectronicAddress exciteEmail = Mailbox.ADDRESS;
owner.sendMessage(embed.build());
LinkedHashSet<MailResponse> wiiMail = Mailbox.packResponses(new TextualMailResponse((Wii) exciteEmail, this, null).setText("This wii has been registered with\n Excitebot.\n" + "registrant: " + owner.getDiscordAuthor().getIdentifierName() + "\n\n" + "If this is not you, contact a TCG\nadmin immediately.\n\n" + "-The Game Community"));
Mailbox.sendResponses(wiiMail);
}
use of com.gamebuster19901.excite.bot.database.Comparison in project ExciteBot by TheGameCommunity.
the class Wii method getRegistrationCode.
public String getRegistrationCode() {
try {
Result result = Table.selectColumnsFromWhere(ConsoleContext.INSTANCE, REGISTRATION_CODE, WIIS, new Comparison(WII_ID, EQUALS, wiiCode));
if (result.next()) {
String ret = result.getString(REGISTRATION_CODE);
if (ret == null) {
generateRegistrationCode();
result = Table.selectColumnsFromWhere(ConsoleContext.INSTANCE, REGISTRATION_CODE, WIIS, new Comparison(WII_ID, EQUALS, wiiCode));
if (result.next()) {
return result.getString(REGISTRATION_CODE);
}
} else {
return ret;
}
} else {
generateRegistrationCode();
result = Table.selectColumnsFromWhere(ConsoleContext.INSTANCE, REGISTRATION_CODE, WIIS, new Comparison(WII_ID, EQUALS, wiiCode));
if (result.next()) {
return result.getString(REGISTRATION_CODE);
}
}
throw new AssertionError();
} catch (SQLException e) {
throw new IOError(e);
}
}
use of com.gamebuster19901.excite.bot.database.Comparison in project ExciteBot by TheGameCommunity.
the class DiscordUser method getDiscordUsersWithUsername.
@Deprecated
@SuppressWarnings("rawtypes")
public static final DiscordUser[] getDiscordUsersWithUsername(MessageContext context, String username) {
try {
ArrayList<DiscordUser> users = new ArrayList<DiscordUser>();
Result results = Table.selectAllFromWhere(context, DISCORD_USERS, new Comparison(DISCORD_NAME, LIKE, Table.makeSafe(username) + "_____"));
while (results.next()) {
users.add(new DiscordUser(results));
}
return users.toArray(new DiscordUser[] {});
} catch (SQLException e) {
throw new IOError(e);
}
}
use of com.gamebuster19901.excite.bot.database.Comparison in project ExciteBot by TheGameCommunity.
the class DiscordUser method getRegisteredWiis.
@Nullable
public Wii[] getRegisteredWiis() {
try {
HashSet<Wii> wiis = new HashSet<Wii>();
Result result = Table.selectColumnsFromWhere(ConsoleContext.INSTANCE, WII_ID, WIIS, new Comparison(DISCORD_ID, EQUALS, getID()));
while (result.next()) {
wiis.add(Wii.getWii(result.getString(WII_ID)));
}
return (Wii[]) wiis.toArray(new Wii[] {});
} catch (SQLException e) {
throw new IOError(e);
}
}
use of com.gamebuster19901.excite.bot.database.Comparison in project ExciteBot by TheGameCommunity.
the class DiscordUser method getDiscordUsersWithUsernameOrID.
@SuppressWarnings("rawtypes")
public static final DiscordUser[] getDiscordUsersWithUsernameOrID(MessageContext context, String usernameOrID) {
try {
if (usernameOrID.indexOf("#") != -1) {
if (usernameOrID.length() > usernameOrID.indexOf('#')) {
String name = usernameOrID.substring(0, usernameOrID.indexOf('#'));
String discriminator = usernameOrID.substring(usernameOrID.indexOf('#') + 1, usernameOrID.length());
DiscordUser user = getDiscordUser(context, name, discriminator);
if (user != null) {
return new DiscordUser[] { user };
}
}
return new DiscordUser[0];
}
ArrayList<DiscordUser> users = new ArrayList<DiscordUser>();
Result results = Table.selectAllFromWhere(context, DISCORD_USERS, new Comparison(DISCORD_NAME, LIKE, Table.makeSafe(usernameOrID) + "_____").or(new Comparison(DISCORD_ID, EQUALS, Table.makeSafe(usernameOrID))));
while (results.next()) {
users.add(new DiscordUser(results));
}
return users.toArray(new DiscordUser[] {});
} catch (SQLException e) {
throw new IOError(e);
}
}
Aggregations