Search in sources :

Example 1 with FreeGameType

use of com.sx4.bot.entities.info.FreeGameType in project Sx4 by sx4-discord-bot.

the class FreeGamesCommand method platforms.

@Command(value = "platforms", description = "Select what platforms you want notifications from")
@CommandId(491)
@Examples({ "free games platforms #channel STEAM", "free games platforms STEAM EPIC_GAMES" })
@AuthorPermissions(permissions = { Permission.MANAGE_SERVER })
public void platforms(Sx4CommandEvent event, @Argument(value = "channel", nullDefault = true) TextChannel channel, @Argument(value = "platforms") FreeGameType... types) {
    TextChannel effectiveChannel = channel == null ? event.getTextChannel() : channel;
    long raw = FreeGameType.getRaw(types);
    event.getMongo().updateFreeGameChannel(Filters.eq("channelId", effectiveChannel.getIdLong()), Updates.set("platforms", raw), new UpdateOptions()).whenComplete((result, exception) -> {
        if (ExceptionUtility.sendExceptionally(event, exception)) {
            return;
        }
        if (result.getMatchedCount() == 0) {
            event.replyFailure("You do not have a free game channel in " + effectiveChannel.getAsMention()).queue();
            return;
        }
        if (result.getModifiedCount() == 0) {
            event.replyFailure("That free game channel already uses those platforms").queue();
            return;
        }
        event.replySuccess("That free game channel will now send notifications from those platforms").queue();
    });
}
Also used : TextChannel(net.dv8tion.jda.api.entities.TextChannel) Command(com.jockie.bot.core.command.Command) Sx4Command(com.sx4.bot.core.Sx4Command)

Aggregations

Command (com.jockie.bot.core.command.Command)1 Sx4Command (com.sx4.bot.core.Sx4Command)1 TextChannel (net.dv8tion.jda.api.entities.TextChannel)1