Search in sources :

Example 6 with Command

use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.

the class BlacklistCommand method onBlacklistAdd.

@Command(value = "add", name = "Benutzer sperren", usage = "{prefix}blacklist add <member>", desc = "Fügt einen Benutzer zur Blacklist hinzu")
public void onBlacklistAdd(CommandEvent event, Member member) {
    BotUser executor = userService.getUserById(event.getAuthor().getIdLong());
    BotUser target = userService.getUserById(member.getIdLong());
    // can only blacklist users with lower permissions
    if (executor.getPermissionLevel() < target.getPermissionLevel()) {
        event.reply(embedCache.getEmbed("memberBlacklistInvalidTarget").injectValue("user", member.getAsMention()));
        return;
    }
    userService.setPermission(member.getIdLong(), 0);
    event.reply(embedCache.getEmbed("memberBlacklistAdd").injectValue("user", member.getAsMention()));
}
Also used : BotUser(de.kaktushose.levelbot.database.model.BotUser) Command(com.github.kaktushose.jda.commands.annotations.Command)

Example 7 with Command

use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.

the class SetPermsCommand method onSetPerms.

@Command(name = "Berechtigung ändern", usage = "{prefix}setperms <member> <level>", desc = "Setzt das Berechtigungslevel eines Benutzers auf den angegebenen Wert")
public void onSetPerms(CommandEvent event, Member member, int level) {
    if (level < 1 || level > 4) {
        event.reply(embedCache.getEmbed("invalidValue").injectValue("min", 1).injectValue("max", 4));
        return;
    }
    BotUser executor = userService.getUserById(event.getAuthor().getIdLong());
    BotUser target = userService.getUserById(member.getIdLong());
    // can only update users with lower perms
    if (executor.getPermissionLevel() < level + 1 || executor.getPermissionLevel() < target.getPermissionLevel()) {
        event.reply(embedCache.getEmbed("permissionSetInvalidTarget").injectValue("user", member.getAsMention()));
        return;
    }
    userService.setPermission(target.getUserId(), level);
    event.reply(embedCache.getEmbed("permissionSet").injectValue("user", member.getAsMention()).injectValue("value", level));
}
Also used : BotUser(de.kaktushose.levelbot.database.model.BotUser) Command(com.github.kaktushose.jda.commands.annotations.Command)

Example 8 with Command

use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.

the class ContestEventCommand method onContestEventStop.

@Command(value = "stop", name = "Contest Event deaktivieren", usage = "{prefix}contest stop", desc = "Stoppt ein Bilder Contest Event", category = "Moderation")
public void onContestEventStop(CommandEvent event) {
    eventService.stopContestEvent(event.getGuild().getIdLong());
    event.reply(embedCache.getEmbed("contestEventStop"));
    List<String> users = eventService.getVoteResult(10, event.getJDA()).getPage();
    EmbedBuilder embedBuilder = embedCache.getEmbed("leaderboard").injectValue("guild", "Contest Event").injectValue("currency", "").toEmbedBuilder();
    StringBuilder result = new StringBuilder();
    for (int i = 0; i < users.size(); i++) {
        result.append(String.format("`%d)` ", i + 1)).append(users.get(i)).append("\n");
    }
    event.reply(embedBuilder.setDescription(result.toString()));
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Command(com.github.kaktushose.jda.commands.annotations.Command)

Example 9 with Command

use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.

the class StopCommand method onStop.

@Command(name = "Bot herunterfahren", usage = "{prefix}stop", desc = "Fährt den Bot herunter", category = "Owner")
public void onStop(CommandEvent event) {
    event.reply(embedCache.getEmbed("confirmAction").injectValue("action", "du den Bot herunterfahren möchtest?\nNur <@393843637437464588> kann den Bot wieder starten!"), confirmMessage -> {
        confirmMessage.addReaction(EmoteType.THUMBSUP.unicode).and(confirmMessage.addReaction(EmoteType.THUMBSDOWN.unicode)).queue();
        ReactionWaiter reactionWaiter = new ReactionWaiter(confirmMessage, event.getMember(), EmoteType.THUMBSUP.unicode, EmoteType.THUMBSDOWN.unicode);
        reactionWaiter.onEvent(reactionEvent -> {
            if (reactionEvent.getEmote().equals(EmoteType.THUMBSUP.unicode)) {
                event.reply("https://tenor.com/view/tekashi-69-fade-out-peace-gif-15141419");
                confirmMessage.delete().queue();
                levelbot.stop().terminate(0);
            }
            reactionWaiter.stopWaiting(true);
        });
    });
}
Also used : ReactionWaiter(de.kaktushose.discord.reactionwaiter.ReactionWaiter) Command(com.github.kaktushose.jda.commands.annotations.Command)

Aggregations

Command (com.github.kaktushose.jda.commands.annotations.Command)9 BotUser (de.kaktushose.levelbot.database.model.BotUser)4 ReactionWaiter (de.kaktushose.discord.reactionwaiter.ReactionWaiter)3 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)2 Item (de.kaktushose.levelbot.shop.data.items.Item)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Member (net.dv8tion.jda.api.entities.Member)1 Message (net.dv8tion.jda.api.entities.Message)1 ErrorHandler (net.dv8tion.jda.api.exceptions.ErrorHandler)1