use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.
the class ChangeDiamondsCommand method onChangeDiamonds.
@Command(name = "Diamanten tauschen", usage = "{prefix}tauschen <anzahl>", desc = "Tauscht Diamanten gegen Münzen ein. Ein Diamant ist 20 Münzen wert")
public void onChangeDiamonds(CommandEvent event, @Optional("1") long amount) {
BotUser botUser = userService.getUserById(event.getAuthor().getIdLong());
long diamonds = botUser.getDiamonds();
long coins = amount * 20;
if (diamonds == 0 || amount > diamonds) {
event.reply(embedCache.getEmbed("missingCurrency").injectValue("currency", "Diamanten"));
return;
}
event.reply(embedCache.getEmbed("confirmAction").injectValue("action", String.format("du %d Diamanten gegen %d Münzen tauschen möchtest?", amount, coins)), 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)) {
userService.exchangeDiamonds(botUser.getUserId(), amount);
confirmMessage.editMessageEmbeds(embedCache.getEmbed("diamondChangeSuccess").injectValue("diamonds", amount).injectValue("coins", coins).toMessageEmbed()).queue();
}
reactionWaiter.stopWaiting(true);
});
});
}
use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.
the class BulkDeleteCommand method onBulkDeleteMessages.
@Command(name = "Nachrichten löschen", usage = "{prefix}delete <amount>", desc = "Löscht die angegebene Zahl von Nachrichten aus einem Channel")
public void onBulkDeleteMessages(CommandEvent event, @Min(value = 1, message = "Muss mindestens eine Nachricht löschen") @Max(value = 100, message = "Kann maximal 100 Nachrichten gleichzeitig löschen") int amount) {
// amount + 1 so we delete the command message as well
// complete aka blocking to make sure that the success message is sent correctly
List<Message> messageHistory = event.getChannel().getHistory().retrievePast(amount + 1).complete();
messageHistory.forEach(message -> message.delete().complete());
event.reply(embedCache.getEmbed("bulkDeleteSuccess").injectValue("amount", amount), message -> message.delete().queueAfter(10, TimeUnit.SECONDS, null, new ErrorHandler().ignore(ErrorResponse.UNKNOWN_MESSAGE)));
// delete success message after 10 secs
}
use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.
the class RemoveItemCommand method onRemoveItem.
@Command(name = "Item entfernen", usage = "{prefix}remove <member>", desc = "Entfernt ein Item aus dem Besitz eines Benutzers", category = "Moderation")
public void onRemoveItem(CommandEvent event, Member member) {
List<Item> items = shopService.getItems(member.getIdLong());
AtomicInteger counter = new AtomicInteger(1);
List<String> emotes = new ArrayList<>();
EmbedBuilder builder = embedCache.getEmbed("removeItem").injectValue("user", member.getAsMention()).toEmbedBuilder();
items.forEach(item -> {
String emote = EmoteType.getNumber(counter.getAndIncrement()).unicode;
emotes.add(emote);
builder.addField(emote + ": " + item.getName(), "", false);
});
event.reply(builder, chooseMessage -> {
emotes.forEach(emote -> chooseMessage.addReaction(emote).queue());
ReactionWaiter reactionWaiter = new ReactionWaiter(chooseMessage, event.getMember(), emotes);
reactionWaiter.onEvent(reactionEvent -> {
Item forRemoval;
switch(reactionEvent.getEmote()) {
case NumberEmojis.ONE:
forRemoval = items.get(0);
break;
case NumberEmojis.TWO:
forRemoval = items.get(1);
break;
case NumberEmojis.THREE:
forRemoval = items.get(2);
break;
case NumberEmojis.FOUR:
forRemoval = items.get(3);
break;
case NumberEmojis.FIVE:
forRemoval = items.get(4);
break;
default:
return;
}
shopService.removeItem(member.getIdLong(), forRemoval.getItemId());
reactionWaiter.stopWaiting(false);
chooseMessage.delete().queue();
event.reply(embedCache.getEmbed("removeItemSuccess").injectValue("user", member.getAsMention()));
});
});
}
use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.
the class RankInfoCommand method onRankInfo.
@Command(name = "Kontoinformation abrufen", usage = "{prefix}info <member>", desc = "Zeigt die Kontoinformationen zu einem User an")
public void onRankInfo(CommandEvent event, @Optional Member member) {
Member target = member == null ? event.getMember() : member;
event.reply(levelbot.generateRankInfo(target.getUser(), false));
}
use of com.github.kaktushose.jda.commands.annotations.Command in project Levelbot by Kaktushose.
the class BlacklistCommand method onBlacklistRemove.
@Command(value = { "remove", "rm" }, name = "Benutzer entsperren", usage = "{prefix}blacklist remove <member>", desc = "Entfernt einen Benutzer von der Blacklist")
public void onBlacklistRemove(CommandEvent event, Member member) {
BotUser target = userService.getUserById(member.getIdLong());
userService.setPermission(member.getIdLong(), 1);
event.reply(embedCache.getEmbed("memberBlacklistRemove").injectValue("user", member.getAsMention()));
}
Aggregations