Skip to content

Commit

Permalink
Added randomSlot slash command
Browse files Browse the repository at this point in the history
  • Loading branch information
Alf-Melmac committed Jul 29, 2021
1 parent f94607b commit f476c0d
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package de.webalf.slotbot.service.bot.command.event;

import de.webalf.slotbot.model.annotations.Command;
import de.webalf.slotbot.model.annotations.SlashCommand;
import de.webalf.slotbot.service.bot.EventBotService;
import de.webalf.slotbot.service.bot.command.DiscordCommand;
import de.webalf.slotbot.service.bot.command.DiscordSlashCommand;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import static de.webalf.slotbot.util.bot.InteractionUtils.finishedSlashCommandAction;
import static de.webalf.slotbot.util.bot.MessageUtils.deleteMessagesInstant;
import static de.webalf.slotbot.util.permissions.BotPermissionHelper.Authorization.NONE;

Expand All @@ -22,7 +26,10 @@
@Command(names = {"randomSlot", "slotRandom", "random"},
description = "Trägt dich auf einem zufälligen Slot im Event ein.",
authorization = NONE)
public class RandomSlot implements DiscordCommand {
@SlashCommand(name = "randomSlot",
description = "Trägt dich auf einem zufälligen Slot im Event ein.",
authorization = NONE)
public class RandomSlot implements DiscordCommand, DiscordSlashCommand {
private final EventBotService eventBotService;

@Override
Expand All @@ -32,4 +39,13 @@ public void execute(Message message, List<String> args) {
eventBotService.randomSlot(message.getChannel().getIdLong(), message.getAuthor().getId());
deleteMessagesInstant(message);
}

@Override
public void execute(SlashCommandEvent event) {
log.trace("Slash command: randomSlot");

eventBotService.randomSlot(event.getChannel().getIdLong(), event.getUser().getId());

finishedSlashCommandAction(event);
}
}

0 comments on commit f476c0d

Please sign in to comment.