Search in sources :

Example 6 with Wii

use of com.gamebuster19901.excite.bot.user.Wii 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);
    }
}
Also used : Comparison(com.gamebuster19901.excite.bot.database.Comparison) SQLException(java.sql.SQLException) IOError(java.io.IOError) HashSet(java.util.HashSet) Result(com.gamebuster19901.excite.bot.database.Result) Nullable(javax.annotation.Nullable)

Example 7 with Wii

use of com.gamebuster19901.excite.bot.user.Wii in project ExciteBot by TheGameCommunity.

the class RegisterCommand method registerWii.

@SuppressWarnings("rawtypes")
private static void registerWii(MessageContext context, String securityCode) {
    if (context.isGuildMessage()) {
        context.deletePromptingMessage(ConsoleContext.INSTANCE, context.getMention() + " - Woah! Send your code to me via direct message! Nobody else should be seeing your registration code!");
        return;
    }
    if (context.isConsoleMessage()) {
        context.sendMessage("This command can only be executed in discord");
        return;
    }
    try {
        Result result = Table.selectColumnsFromWhere(context, Column.WII_ID, Table.WIIS, new Comparison(Column.REGISTRATION_CODE, Comparator.EQUALS, securityCode));
        if (result.hasNext()) {
            result.next();
            Wii wii = Wii.getWii(result.getString(Column.WII_ID));
            wii.register(context);
        } else {
            context.sendMessage("Unknown registration code.");
        }
    } catch (SQLException | MessagingException e) {
        context.sendMessage(StacktraceUtil.getStackTrace(e));
    }
}
Also used : Comparison(com.gamebuster19901.excite.bot.database.Comparison) SQLException(java.sql.SQLException) MessagingException(javax.mail.MessagingException) Wii(com.gamebuster19901.excite.bot.user.Wii) Result(com.gamebuster19901.excite.bot.database.Result)

Aggregations

SQLException (java.sql.SQLException)4 Comparison (com.gamebuster19901.excite.bot.database.Comparison)3 Wii (com.gamebuster19901.excite.bot.user.Wii)3 HashSet (java.util.HashSet)3 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)3 Result (com.gamebuster19901.excite.bot.database.Result)2 DiscordUser (com.gamebuster19901.excite.bot.user.DiscordUser)2 IOError (java.io.IOError)2 Duration (java.time.Duration)2 Instant (java.time.Instant)2 Member (net.dv8tion.jda.api.entities.Member)2 Player (com.gamebuster19901.excite.Player)1 Wiimmfi (com.gamebuster19901.excite.Wiimmfi)1 WorkerStatus (com.gamebuster19901.excite.bot.command.ArchiveCommand.WorkerStatus)1 PreparedStatement (com.gamebuster19901.excite.bot.database.sql.PreparedStatement)1 ElectronicAddress (com.gamebuster19901.excite.bot.mail.ElectronicAddress)1 MailResponse (com.gamebuster19901.excite.bot.mail.MailResponse)1 Mailbox (com.gamebuster19901.excite.bot.mail.Mailbox)1 TextualMailResponse (com.gamebuster19901.excite.bot.mail.TextualMailResponse)1 DiscordServer (com.gamebuster19901.excite.bot.server.DiscordServer)1