use of com.gamebuster19901.excite.bot.user.DiscordUser in project ExciteBot by TheGameCommunity.
the class DiscordUser method addDiscordUser.
@SuppressWarnings("rawtypes")
private static DiscordUser addDiscordUser(MessageContext context, long discordID, String name) throws SQLException {
PreparedStatement ps = null;
try {
ps = context.getConnection().prepareStatement("INSERT INTO " + DISCORD_USERS + " (" + DISCORD_ID + ", " + DISCORD_NAME + ", " + LAST_NOTIFICATION + ") VALUES (?, ?, ?);");
Table.insertValue(ps, 1, discordID);
Table.insertValue(ps, 2, name);
Table.insertValue(ps, 3, TimeUtils.PLAYER_EPOCH);
ps.execute();
} catch (Exception e) {
ConsoleUser.getConsoleUser().sendMessage(ps.toString());
throw new IOError(e);
}
return getDiscordUser(context, discordID);
}
use of com.gamebuster19901.excite.bot.user.DiscordUser in project ExciteBot by TheGameCommunity.
the class DiscordUser method notifyDiscordUsers.
public static void notifyDiscordUsers() throws SQLException {
int count = Wiimmfi.getAcknowledgedPlayerCount();
Result result = Table.selectAllFrom(ConsoleContext.INSTANCE, DISCORD_USERS);
while (result.next()) {
int threshold = result.getInt(THRESHOLD);
if (count < threshold) {
new DiscordUser(result).setDippedBelowThreshold(true);
continue;
} else {
if (Instant.parse(result.getString(LAST_NOTIFICATION)).plus(Duration.parse(result.getString(FREQUENCY))).isBefore(Instant.now())) {
if (result.getBoolean(BELOW_THRESHOLD)) {
DiscordUser user = new DiscordUser(result);
if (!result.getBoolean(NOTIFY_CONTINUOUSLY)) {
user.setDippedBelowThreshold(false);
}
if (threshold != -1) {
for (Player player : Wiimmfi.getOnlinePlayers()) {
if (player.getDiscord() == result.getLong(DISCORD_ID)) {
return;
}
}
user.sendMessage("Players Online" + Wiimmfi.getOnlinePlayerList(user.sendDetailedPM()));
user.setLastNotification();
}
}
}
}
}
}
use of com.gamebuster19901.excite.bot.user.DiscordUser in project ExciteBot by TheGameCommunity.
the class DiscordUser method getAllOperators.
public static DiscordUser[] getAllOperators() {
try {
PreparedStatement st = ConsoleContext.INSTANCE.getConnection().prepareStatement("SELECT * FROM discord_users INNER JOIN operators ON(discord_users.discordID = operators.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.user.DiscordUser in project ExciteBot by TheGameCommunity.
the class RankChangeAudit method addRankChange.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static RankChangeAudit addRankChange(MessageContext context, DiscordUser promotee, String rank, boolean added) {
Audit parent = Audit.addAudit(ConsoleContext.INSTANCE, context, AuditType.RANK_CHANGE_AUDIT, getMessage(context, new MessageContext(promotee), rank, added));
PreparedStatement st;
try {
st = Insertion.insertInto(AUDIT_RANK_CHANGES).setColumns(AUDIT_ID, PROMOTEE, PROMOTEE_ID).to(parent.getID(), promotee, promotee.getID()).prepare(ConsoleContext.INSTANCE, true);
st.execute();
RankChangeAudit ret = getRankChangeAuditByID(ConsoleContext.INSTANCE, parent.getID());
ret.parentData = parent;
return ret;
} catch (SQLException e) {
throw new IOError(e);
}
}
use of com.gamebuster19901.excite.bot.user.DiscordUser in project ExciteBot by TheGameCommunity.
the class Banee method getBanee.
@SuppressWarnings("rawtypes")
public static Banee getBanee(MessageContext context, long id) {
DiscordUser discord = DiscordUser.getDiscordUserIncludingUnknown(context, id);
Player player = Player.getPlayerByID(context, (int) id);
if (!player.isKnown()) {
return discord;
}
return player;
}
Aggregations