(wip) migrate commands to components
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -13,19 +13,6 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|||||||
import wtf.beatrice.hidekobot.commands.completer.ProfileImageCommandCompleter;
|
import wtf.beatrice.hidekobot.commands.completer.ProfileImageCommandCompleter;
|
||||||
import wtf.beatrice.hidekobot.commands.message.*;
|
import wtf.beatrice.hidekobot.commands.message.*;
|
||||||
import wtf.beatrice.hidekobot.commands.slash.*;
|
import wtf.beatrice.hidekobot.commands.slash.*;
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashBanCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashBannerCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashClearCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashCoinFlipCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashDiceRollCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashInviteCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashKickCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashLoveCalculatorCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashMagicBallCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashSayCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashTimeoutCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashTriviaCommand;
|
|
||||||
import wtf.beatrice.hidekobot.commands.slash.SlashUrbanDictionaryCommand;
|
|
||||||
import wtf.beatrice.hidekobot.datasources.ConfigurationSource;
|
import wtf.beatrice.hidekobot.datasources.ConfigurationSource;
|
||||||
import wtf.beatrice.hidekobot.datasources.PropertiesSource;
|
import wtf.beatrice.hidekobot.datasources.PropertiesSource;
|
||||||
import wtf.beatrice.hidekobot.listeners.*;
|
import wtf.beatrice.hidekobot.listeners.*;
|
||||||
@@ -163,48 +150,48 @@ public class HidekoBot
|
|||||||
MessageCommandListener messageCommandListener = context.getBean(MessageCommandListener.class);
|
MessageCommandListener messageCommandListener = context.getBean(MessageCommandListener.class);
|
||||||
ButtonInteractionListener buttonInteractionListener = context.getBean(ButtonInteractionListener.class);
|
ButtonInteractionListener buttonInteractionListener = context.getBean(ButtonInteractionListener.class);
|
||||||
SelectMenuInteractionListener selectMenuInteractionListener = context.getBean(SelectMenuInteractionListener.class);
|
SelectMenuInteractionListener selectMenuInteractionListener = context.getBean(SelectMenuInteractionListener.class);
|
||||||
SlashAvatarCommand slashAvatarCommand = new SlashAvatarCommand();
|
SlashAvatarCommand slashAvatarCommand = context.getBean(SlashAvatarCommand.class);
|
||||||
ProfileImageCommandCompleter avatarCommandCompleter = new ProfileImageCommandCompleter(slashAvatarCommand);
|
ProfileImageCommandCompleter avatarCommandCompleter = new ProfileImageCommandCompleter(slashAvatarCommand);
|
||||||
slashCommandListener.registerCommand(slashAvatarCommand);
|
slashCommandListener.registerCommand(slashAvatarCommand);
|
||||||
slashCommandCompletionListener.registerCommandCompleter(avatarCommandCompleter);
|
slashCommandCompletionListener.registerCommandCompleter(avatarCommandCompleter);
|
||||||
slashCommandListener.registerCommand(new SlashBanCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashBanCommand.class));
|
||||||
SlashBannerCommand slashBannerCommand = new SlashBannerCommand();
|
SlashBannerCommand slashBannerCommand = context.getBean(SlashBannerCommand.class);
|
||||||
ProfileImageCommandCompleter bannerCommandCompleter = new ProfileImageCommandCompleter(slashBannerCommand);
|
ProfileImageCommandCompleter bannerCommandCompleter = new ProfileImageCommandCompleter(slashBannerCommand);
|
||||||
slashCommandListener.registerCommand(slashBannerCommand);
|
slashCommandListener.registerCommand(slashBannerCommand);
|
||||||
slashCommandCompletionListener.registerCommandCompleter(bannerCommandCompleter);
|
slashCommandCompletionListener.registerCommandCompleter(bannerCommandCompleter);
|
||||||
slashCommandListener.registerCommand(context.getBean(SlashBotInfoCommand.class));
|
slashCommandListener.registerCommand(context.getBean(SlashBotInfoCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashClearCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashClearCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashCoinFlipCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashCoinFlipCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashDiceRollCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashDiceRollCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashDieCommand());
|
slashCommandListener.registerCommand(new SlashDieCommand());
|
||||||
slashCommandListener.registerCommand(new SlashHelpCommand());
|
slashCommandListener.registerCommand(new SlashHelpCommand());
|
||||||
slashCommandListener.registerCommand(new SlashInviteCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashInviteCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashKickCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashKickCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashLoveCalculatorCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashLoveCalculatorCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashMagicBallCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashMagicBallCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashPingCommand());
|
slashCommandListener.registerCommand(new SlashPingCommand());
|
||||||
slashCommandListener.registerCommand(new SlashSayCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashSayCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashTimeoutCommand());
|
slashCommandListener.registerCommand(context.getBean(SlashTimeoutCommand.class));
|
||||||
slashCommandListener.registerCommand(new SlashTriviaCommand());
|
slashCommandListener.registerCommand(new SlashTriviaCommand());
|
||||||
slashCommandListener.registerCommand(new SlashUrbanDictionaryCommand());
|
slashCommandListener.registerCommand(new SlashUrbanDictionaryCommand());
|
||||||
|
|
||||||
// register message commands
|
// register message commands
|
||||||
messageCommandListener.registerCommand(new MessageHelloCommand());
|
messageCommandListener.registerCommand(new MessageHelloCommand());
|
||||||
messageCommandListener.registerCommand(context.getBean(MessageAliasCommand.class));
|
messageCommandListener.registerCommand(context.getBean(MessageAliasCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageAvatarCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageAvatarCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageBanCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageBanCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageBannerCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageBannerCommand.class));
|
||||||
messageCommandListener.registerCommand(context.getBean(MessageBotInfoCommand.class));
|
messageCommandListener.registerCommand(context.getBean(MessageBotInfoCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageCoinFlipCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageCoinFlipCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageClearCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageClearCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageDiceRollCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageDiceRollCommand.class));
|
||||||
messageCommandListener.registerCommand(context.getBean(MessageHelpCommand.class));
|
messageCommandListener.registerCommand(context.getBean(MessageHelpCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageInviteCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageInviteCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageKickCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageKickCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageLoveCalculatorCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageLoveCalculatorCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageMagicBallCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageMagicBallCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageSayCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageSayCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageTimeoutCommand());
|
messageCommandListener.registerCommand(context.getBean(MessageTimeoutCommand.class));
|
||||||
messageCommandListener.registerCommand(new MessageTriviaCommand());
|
messageCommandListener.registerCommand(new MessageTriviaCommand());
|
||||||
messageCommandListener.registerCommand(new MessageUrbanDictionaryCommand());
|
messageCommandListener.registerCommand(new MessageUrbanDictionaryCommand());
|
||||||
|
|
||||||
|
@@ -8,33 +8,30 @@ import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
|||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class ClearChat
|
public class ClearChat
|
||||||
{
|
{
|
||||||
private ClearChat()
|
public String getLabel()
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLabel()
|
|
||||||
{
|
{
|
||||||
return "clear";
|
return "clear";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return "Clear the current channel's chat.";
|
return "Clear the current channel's chat.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Permission getPermission()
|
public Permission getPermission()
|
||||||
{
|
{
|
||||||
return Permission.MESSAGE_MANAGE;
|
return Permission.MESSAGE_MANAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String checkDMs(Channel channel)
|
public String checkDMs(Channel channel)
|
||||||
{
|
{
|
||||||
if (!(channel instanceof TextChannel))
|
if (!(channel instanceof TextChannel))
|
||||||
{
|
{
|
||||||
@@ -44,7 +41,7 @@ public class ClearChat
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String checkDeleteAmount(int toDeleteAmount)
|
public String checkDeleteAmount(int toDeleteAmount)
|
||||||
{
|
{
|
||||||
if (toDeleteAmount <= 0)
|
if (toDeleteAmount <= 0)
|
||||||
{
|
{
|
||||||
@@ -54,9 +51,9 @@ public class ClearChat
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int delete(int toDeleteAmount,
|
public int delete(int toDeleteAmount,
|
||||||
long startingMessageId,
|
long startingMessageId,
|
||||||
MessageChannel channel)
|
MessageChannel channel)
|
||||||
{
|
{
|
||||||
// int to keep track of how many messages we actually deleted.
|
// int to keep track of how many messages we actually deleted.
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
@@ -158,13 +155,13 @@ public class ClearChat
|
|||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Button getDismissButton()
|
public Button getDismissButton()
|
||||||
{
|
{
|
||||||
return Button.primary("generic_dismiss", "Dismiss")
|
return Button.primary("generic_dismiss", "Dismiss")
|
||||||
.withEmoji(Emoji.fromUnicode("❌"));
|
.withEmoji(Emoji.fromUnicode("❌"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String parseAmount(int deleted)
|
public String parseAmount(int deleted)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (deleted < 1)
|
if (deleted < 1)
|
||||||
@@ -180,7 +177,7 @@ public class ClearChat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cap the amount to avoid abuse.
|
// cap the amount to avoid abuse.
|
||||||
public static int getMaxAmount()
|
public int getMaxAmount()
|
||||||
{
|
{
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
@@ -6,27 +6,23 @@ import net.dv8tion.jda.api.entities.emoji.Emoji;
|
|||||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.util.RandomUtil;
|
import wtf.beatrice.hidekobot.util.RandomUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class CoinFlip
|
public class CoinFlip
|
||||||
{
|
{
|
||||||
|
public Button getReflipButton()
|
||||||
private CoinFlip()
|
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Button getReflipButton()
|
|
||||||
{
|
{
|
||||||
return Button.primary("coinflip_reflip", "Flip again")
|
return Button.primary("coinflip_reflip", "Flip again")
|
||||||
.withEmoji(Emoji.fromUnicode("\uD83E\uDE99"));
|
.withEmoji(Emoji.fromUnicode("\uD83E\uDE99"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String genRandom()
|
public String genRandom()
|
||||||
{
|
{
|
||||||
int rand = RandomUtil.getRandomNumber(0, 1);
|
int rand = RandomUtil.getRandomNumber(0, 1);
|
||||||
String msg;
|
String msg;
|
||||||
@@ -42,7 +38,7 @@ public class CoinFlip
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void buttonReFlip(ButtonInteractionEvent event)
|
public void buttonReFlip(ButtonInteractionEvent event)
|
||||||
{
|
{
|
||||||
// Ack ASAP to avoid 3s timeout
|
// Ack ASAP to avoid 3s timeout
|
||||||
event.deferEdit().queue(hook -> {
|
event.deferEdit().queue(hook -> {
|
||||||
@@ -86,7 +82,7 @@ public class CoinFlip
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void trackAndRestrict(Message replyMessage, User user)
|
public void trackAndRestrict(Message replyMessage, User user)
|
||||||
{
|
{
|
||||||
Cache.getServices().databaseService().queueDisabling(replyMessage);
|
Cache.getServices().databaseService().queueDisabling(replyMessage);
|
||||||
Cache.getServices().databaseService().trackRanCommandReply(replyMessage, user);
|
Cache.getServices().databaseService().trackRanCommandReply(replyMessage, user);
|
||||||
|
@@ -2,6 +2,7 @@ package wtf.beatrice.hidekobot.commands.base;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
import wtf.beatrice.hidekobot.objects.fun.Dice;
|
import wtf.beatrice.hidekobot.objects.fun.Dice;
|
||||||
@@ -12,15 +13,11 @@ import java.util.LinkedList;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class DiceRoll
|
public class DiceRoll
|
||||||
{
|
{
|
||||||
|
|
||||||
private DiceRoll()
|
public MessageResponse buildResponse(User author, String[] args)
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MessageResponse buildResponse(User author, String[] args)
|
|
||||||
{
|
{
|
||||||
LinkedHashMap<Dice, Integer> dicesToRoll = new LinkedHashMap<>();
|
LinkedHashMap<Dice, Integer> dicesToRoll = new LinkedHashMap<>();
|
||||||
String diceRegex = "d\\d+";
|
String diceRegex = "d\\d+";
|
||||||
|
@@ -4,18 +4,15 @@ import net.dv8tion.jda.api.EmbedBuilder;
|
|||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.HidekoBot;
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class Invite
|
public class Invite
|
||||||
{
|
{
|
||||||
|
|
||||||
private Invite()
|
public MessageEmbed generateEmbed()
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MessageEmbed generateEmbed()
|
|
||||||
{
|
{
|
||||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
|
|
||||||
@@ -33,7 +30,7 @@ public class Invite
|
|||||||
return embedBuilder.build();
|
return embedBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Button getInviteButton()
|
public Button getInviteButton()
|
||||||
{
|
{
|
||||||
String inviteUrl = Cache.getInviteUrl();
|
String inviteUrl = Cache.getInviteUrl();
|
||||||
return Button.link(inviteUrl, "Invite " + Cache.getBotName())
|
return Button.link(inviteUrl, "Invite " + Cache.getBotName())
|
||||||
|
@@ -3,20 +3,17 @@ package wtf.beatrice.hidekobot.commands.base;
|
|||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.util.RandomUtil;
|
import wtf.beatrice.hidekobot.util.RandomUtil;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class LoveCalculator
|
public class LoveCalculator
|
||||||
{
|
{
|
||||||
|
|
||||||
private LoveCalculator()
|
public MessageEmbed buildEmbedAndCacheResult(User author, User user1, User user2)
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MessageEmbed buildEmbedAndCacheResult(User author, User user1, User user2)
|
|
||||||
{
|
{
|
||||||
String userId1 = user1.getId();
|
String userId1 = user1.getId();
|
||||||
String userId2 = user2.getId();
|
String userId2 = user2.getId();
|
||||||
|
@@ -3,6 +3,7 @@ package wtf.beatrice.hidekobot.commands.base;
|
|||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.util.RandomUtil;
|
import wtf.beatrice.hidekobot.util.RandomUtil;
|
||||||
|
|
||||||
@@ -11,20 +12,16 @@ import java.util.Arrays;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MagicBall
|
public class MagicBall
|
||||||
{
|
{
|
||||||
|
|
||||||
private MagicBall()
|
public LinkedList<String> getLabels()
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinkedList<String> getLabels()
|
|
||||||
{
|
{
|
||||||
return new LinkedList<>(Arrays.asList("8ball", "8b", "eightball", "magicball"));
|
return new LinkedList<>(Arrays.asList("8ball", "8b", "eightball", "magicball"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<String> answers = new ArrayList<>(
|
private final List<String> answers = new ArrayList<>(
|
||||||
Arrays.asList("It is certain.",
|
Arrays.asList("It is certain.",
|
||||||
"It is decidedly so.",
|
"It is decidedly so.",
|
||||||
"Without a doubt.",
|
"Without a doubt.",
|
||||||
@@ -46,13 +43,13 @@ public class MagicBall
|
|||||||
"Outlook not so good.",
|
"Outlook not so good.",
|
||||||
"Very doubtful."));
|
"Very doubtful."));
|
||||||
|
|
||||||
public static String getRandomAnswer()
|
public String getRandomAnswer()
|
||||||
{
|
{
|
||||||
int answerPos = RandomUtil.getRandomNumber(0, answers.size() - 1);
|
int answerPos = RandomUtil.getRandomNumber(0, answers.size() - 1);
|
||||||
return answers.get(answerPos);
|
return answers.get(answerPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageEmbed generateEmbed(String question, User author)
|
public MessageEmbed generateEmbed(String question, User author)
|
||||||
{
|
{
|
||||||
// add a question mark at the end, if missing.
|
// add a question mark at the end, if missing.
|
||||||
// this might not always apply but it's fun
|
// this might not always apply but it's fun
|
||||||
|
@@ -3,18 +3,15 @@ package wtf.beatrice.hidekobot.commands.base;
|
|||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
import net.dv8tion.jda.api.utils.ImageProxy;
|
import net.dv8tion.jda.api.utils.ImageProxy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class ProfileImage
|
public class ProfileImage
|
||||||
{
|
{
|
||||||
|
|
||||||
private ProfileImage()
|
public int parseResolution(int resolution)
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int parseResolution(int resolution)
|
|
||||||
{
|
{
|
||||||
int[] acceptedSizes = Cache.getSupportedAvatarResolutions();
|
int[] acceptedSizes = Cache.getSupportedAvatarResolutions();
|
||||||
|
|
||||||
@@ -34,7 +31,7 @@ public class ProfileImage
|
|||||||
return acceptedSizes[idx];
|
return acceptedSizes[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageResponse buildResponse(int resolution, User user, ImageType imageType)
|
public MessageResponse buildResponse(int resolution, User user, ImageType imageType)
|
||||||
{
|
{
|
||||||
String imageTypeName = imageType.name().toLowerCase();
|
String imageTypeName = imageType.name().toLowerCase();
|
||||||
String resolutionString;
|
String resolutionString;
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
package wtf.beatrice.hidekobot.commands.base;
|
package wtf.beatrice.hidekobot.commands.base;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class Say
|
public class Say
|
||||||
{
|
{
|
||||||
|
public Permission getPermission()
|
||||||
private Say()
|
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Permission getPermission()
|
|
||||||
{
|
{
|
||||||
return Permission.MESSAGE_MANAGE;
|
return Permission.MESSAGE_MANAGE;
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||||
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
|
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.HidekoBot;
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
@@ -24,18 +25,14 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class UserPunishment
|
public class UserPunishment
|
||||||
{
|
{
|
||||||
|
|
||||||
private UserPunishment()
|
|
||||||
{
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Duration maxTimeoutDuration = Duration.of(28, ChronoUnit.DAYS);
|
private static final Duration maxTimeoutDuration = Duration.of(28, ChronoUnit.DAYS);
|
||||||
private static final Duration minTimeoutDuration = Duration.of(30, ChronoUnit.SECONDS);
|
private static final Duration minTimeoutDuration = Duration.of(30, ChronoUnit.SECONDS);
|
||||||
|
|
||||||
public static void handle(SlashCommandInteractionEvent event, PunishmentType punishmentType)
|
public void handle(SlashCommandInteractionEvent event, PunishmentType punishmentType)
|
||||||
{
|
{
|
||||||
// this might take a sec
|
// this might take a sec
|
||||||
event.deferReply().queue();
|
event.deferReply().queue();
|
||||||
@@ -92,7 +89,7 @@ public class UserPunishment
|
|||||||
event.getHook().editOriginal(response.content()).queue();
|
event.getHook().editOriginal(response.content()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(MessageReceivedEvent event, String[] args, PunishmentType punishmentType)
|
public void handle(MessageReceivedEvent event, String[] args, PunishmentType punishmentType)
|
||||||
{
|
{
|
||||||
Mentions msgMentions = event.getMessage().getMentions();
|
Mentions msgMentions = event.getMessage().getMentions();
|
||||||
List<IMentionable> mentions = msgMentions.getMentions();
|
List<IMentionable> mentions = msgMentions.getMentions();
|
||||||
@@ -109,11 +106,11 @@ public class UserPunishment
|
|||||||
event.getMessage().reply(response.content()).queue();
|
event.getMessage().reply(response.content()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageResponse getResponse(User author,
|
public MessageResponse getResponse(User author,
|
||||||
PunishmentType punishmentType,
|
PunishmentType punishmentType,
|
||||||
MessageChannelUnion channel,
|
MessageChannelUnion channel,
|
||||||
List<IMentionable> mentions,
|
List<IMentionable> mentions,
|
||||||
String[] args)
|
String[] args)
|
||||||
{
|
{
|
||||||
String punishmentTypeName = punishmentType.name().toLowerCase();
|
String punishmentTypeName = punishmentType.name().toLowerCase();
|
||||||
|
|
||||||
|
@@ -6,6 +6,8 @@ import net.dv8tion.jda.api.entities.User;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.HidekoBot;
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
@@ -16,8 +18,15 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageAvatarCommand implements MessageCommand
|
public class MessageAvatarCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final ProfileImage profileImage;
|
||||||
|
|
||||||
|
public MessageAvatarCommand(@Autowired ProfileImage profileImage)
|
||||||
|
{
|
||||||
|
this.profileImage = profileImage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
@@ -74,7 +83,7 @@ public class MessageAvatarCommand implements MessageCommand
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
int givenRes = Integer.parseInt(arg);
|
int givenRes = Integer.parseInt(arg);
|
||||||
resolution = ProfileImage.parseResolution(givenRes);
|
resolution = profileImage.parseResolution(givenRes);
|
||||||
resFound = true;
|
resFound = true;
|
||||||
break;
|
break;
|
||||||
} catch (NumberFormatException ignored)
|
} catch (NumberFormatException ignored)
|
||||||
@@ -84,7 +93,7 @@ public class MessageAvatarCommand implements MessageCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fallback in case we didn't find any specified resolution
|
// fallback in case we didn't find any specified resolution
|
||||||
if (!resFound) resolution = ProfileImage.parseResolution(512);
|
if (!resFound) resolution = profileImage.parseResolution(512);
|
||||||
|
|
||||||
// check if someone is mentioned
|
// check if someone is mentioned
|
||||||
Mentions mentions = event.getMessage().getMentions();
|
Mentions mentions = event.getMessage().getMentions();
|
||||||
@@ -101,7 +110,7 @@ public class MessageAvatarCommand implements MessageCommand
|
|||||||
if (user == null) user = event.getAuthor();
|
if (user == null) user = event.getAuthor();
|
||||||
|
|
||||||
// send a response
|
// send a response
|
||||||
MessageResponse response = ProfileImage.buildResponse(resolution, user, ProfileImage.ImageType.AVATAR);
|
MessageResponse response = profileImage.buildResponse(resolution, user, ProfileImage.ImageType.AVATAR);
|
||||||
if (response.content() != null)
|
if (response.content() != null)
|
||||||
{
|
{
|
||||||
event.getMessage().reply(response.content()).queue();
|
event.getMessage().reply(response.content()).queue();
|
||||||
|
@@ -4,6 +4,8 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||||
@@ -13,8 +15,15 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageBanCommand implements MessageCommand
|
public class MessageBanCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final UserPunishment userPunishment;
|
||||||
|
|
||||||
|
public MessageBanCommand(@Autowired UserPunishment userPunishment)
|
||||||
|
{
|
||||||
|
this.userPunishment = userPunishment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
@@ -59,6 +68,6 @@ public class MessageBanCommand implements MessageCommand
|
|||||||
@Override
|
@Override
|
||||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||||
{
|
{
|
||||||
UserPunishment.handle(event, args, UserPunishment.PunishmentType.BAN);
|
userPunishment.handle(event, args, UserPunishment.PunishmentType.BAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,8 @@ import net.dv8tion.jda.api.entities.User;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.HidekoBot;
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
@@ -16,8 +18,15 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageBannerCommand implements MessageCommand
|
public class MessageBannerCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final ProfileImage profileImage;
|
||||||
|
|
||||||
|
public MessageBannerCommand(@Autowired ProfileImage profileImage)
|
||||||
|
{
|
||||||
|
this.profileImage = profileImage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
@@ -74,7 +83,7 @@ public class MessageBannerCommand implements MessageCommand
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
int givenRes = Integer.parseInt(arg);
|
int givenRes = Integer.parseInt(arg);
|
||||||
resolution = ProfileImage.parseResolution(givenRes);
|
resolution = profileImage.parseResolution(givenRes);
|
||||||
resFound = true;
|
resFound = true;
|
||||||
break;
|
break;
|
||||||
} catch (NumberFormatException ignored)
|
} catch (NumberFormatException ignored)
|
||||||
@@ -84,7 +93,7 @@ public class MessageBannerCommand implements MessageCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fallback in case we didn't find any specified resolution
|
// fallback in case we didn't find any specified resolution
|
||||||
if (!resFound) resolution = ProfileImage.parseResolution(512);
|
if (!resFound) resolution = profileImage.parseResolution(512);
|
||||||
|
|
||||||
// check if someone is mentioned
|
// check if someone is mentioned
|
||||||
Mentions mentions = event.getMessage().getMentions();
|
Mentions mentions = event.getMessage().getMentions();
|
||||||
@@ -101,7 +110,7 @@ public class MessageBannerCommand implements MessageCommand
|
|||||||
if (user == null) user = event.getAuthor();
|
if (user == null) user = event.getAuthor();
|
||||||
|
|
||||||
// send a response
|
// send a response
|
||||||
MessageResponse response = ProfileImage.buildResponse(resolution, user, ProfileImage.ImageType.BANNER);
|
MessageResponse response = profileImage.buildResponse(resolution, user, ProfileImage.ImageType.BANNER);
|
||||||
if (response.content() != null)
|
if (response.content() != null)
|
||||||
{
|
{
|
||||||
event.getMessage().reply(response.content()).queue();
|
event.getMessage().reply(response.content()).queue();
|
||||||
|
@@ -6,6 +6,8 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|||||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.commands.base.ClearChat;
|
import wtf.beatrice.hidekobot.commands.base.ClearChat;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
@@ -15,19 +17,27 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageClearCommand implements MessageCommand
|
public class MessageClearCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final ClearChat clearChat;
|
||||||
|
|
||||||
|
public MessageClearCommand(@Autowired ClearChat clearChat)
|
||||||
|
{
|
||||||
|
this.clearChat = clearChat;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
{
|
{
|
||||||
return new LinkedList<>(Collections.singletonList(ClearChat.getLabel()));
|
return new LinkedList<>(Collections.singletonList(clearChat.getLabel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Permission> getPermissions()
|
public List<Permission> getPermissions()
|
||||||
{
|
{
|
||||||
return Collections.singletonList(ClearChat.getPermission());
|
return Collections.singletonList(clearChat.getPermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,7 +71,7 @@ public class MessageClearCommand implements MessageCommand
|
|||||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||||
{
|
{
|
||||||
// check if user is trying to run command in dms.
|
// check if user is trying to run command in dms.
|
||||||
String error = ClearChat.checkDMs(event.getChannel());
|
String error = clearChat.checkDMs(event.getChannel());
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
event.getMessage().reply(error).queue();
|
event.getMessage().reply(error).queue();
|
||||||
@@ -83,9 +93,9 @@ public class MessageClearCommand implements MessageCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cap the amount to avoid abuse.
|
// cap the amount to avoid abuse.
|
||||||
if (toDeleteAmount > ClearChat.getMaxAmount()) toDeleteAmount = 0;
|
if (toDeleteAmount > clearChat.getMaxAmount()) toDeleteAmount = 0;
|
||||||
|
|
||||||
error = ClearChat.checkDeleteAmount(toDeleteAmount);
|
error = clearChat.checkDeleteAmount(toDeleteAmount);
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
event.getMessage().reply(error).queue();
|
event.getMessage().reply(error).queue();
|
||||||
@@ -96,15 +106,15 @@ public class MessageClearCommand implements MessageCommand
|
|||||||
String content = "\uD83D\uDEA7 Clearing...";
|
String content = "\uD83D\uDEA7 Clearing...";
|
||||||
Message botMessage = event.getMessage().reply(content).complete();
|
Message botMessage = event.getMessage().reply(content).complete();
|
||||||
|
|
||||||
int deleted = ClearChat.delete(toDeleteAmount,
|
int deleted = clearChat.delete(toDeleteAmount,
|
||||||
event.getMessageIdLong(),
|
event.getMessageIdLong(),
|
||||||
event.getChannel());
|
event.getChannel());
|
||||||
|
|
||||||
// get a nicely formatted message that logs the deletion of messages.
|
// get a nicely formatted message that logs the deletion of messages.
|
||||||
content = ClearChat.parseAmount(deleted);
|
content = clearChat.parseAmount(deleted);
|
||||||
|
|
||||||
// edit the message text and attach a button.
|
// edit the message text and attach a button.
|
||||||
Button dismiss = ClearChat.getDismissButton();
|
Button dismiss = clearChat.getDismissButton();
|
||||||
Message finalMessage = event.getChannel().sendMessage(content).setActionRow(dismiss).complete();
|
Message finalMessage = event.getChannel().sendMessage(content).setActionRow(dismiss).complete();
|
||||||
|
|
||||||
// add the message to database.
|
// add the message to database.
|
||||||
|
@@ -4,6 +4,8 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.CoinFlip;
|
import wtf.beatrice.hidekobot.commands.base.CoinFlip;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||||
@@ -12,9 +14,17 @@ import java.util.Arrays;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageCoinFlipCommand implements MessageCommand
|
public class MessageCoinFlipCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final CoinFlip coinFlip;
|
||||||
|
|
||||||
|
public MessageCoinFlipCommand(@Autowired CoinFlip coinFlip)
|
||||||
|
{
|
||||||
|
this.coinFlip = coinFlip;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
{
|
{
|
||||||
@@ -60,12 +70,12 @@ public class MessageCoinFlipCommand implements MessageCommand
|
|||||||
{
|
{
|
||||||
|
|
||||||
// perform coin flip
|
// perform coin flip
|
||||||
event.getMessage().reply(CoinFlip.genRandom())
|
event.getMessage().reply(coinFlip.genRandom())
|
||||||
.addActionRow(CoinFlip.getReflipButton())
|
.addActionRow(coinFlip.getReflipButton())
|
||||||
.queue((message) ->
|
.queue((message) ->
|
||||||
{
|
{
|
||||||
// set the command as expiring and restrict it to the user who ran it
|
// set the command as expiring and restrict it to the user who ran it
|
||||||
CoinFlip.trackAndRestrict(message, event.getAuthor());
|
coinFlip.trackAndRestrict(message, event.getAuthor());
|
||||||
}, (error) -> {
|
}, (error) -> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,8 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.DiceRoll;
|
import wtf.beatrice.hidekobot.commands.base.DiceRoll;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
@@ -13,8 +15,16 @@ import java.util.Arrays;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageDiceRollCommand implements MessageCommand
|
public class MessageDiceRollCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final DiceRoll diceRoll;
|
||||||
|
|
||||||
|
public MessageDiceRollCommand(@Autowired DiceRoll diceRoll)
|
||||||
|
{
|
||||||
|
this.diceRoll = diceRoll;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
{
|
{
|
||||||
@@ -66,7 +76,7 @@ public class MessageDiceRollCommand implements MessageCommand
|
|||||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
MessageResponse response = DiceRoll.buildResponse(event.getAuthor(), args);
|
MessageResponse response = diceRoll.buildResponse(event.getAuthor(), args);
|
||||||
|
|
||||||
if (response.content() != null)
|
if (response.content() != null)
|
||||||
{
|
{
|
||||||
|
@@ -7,6 +7,8 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|||||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.Invite;
|
import wtf.beatrice.hidekobot.commands.base.Invite;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||||
@@ -15,8 +17,15 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageInviteCommand implements MessageCommand
|
public class MessageInviteCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final Invite invite;
|
||||||
|
|
||||||
|
public MessageInviteCommand(@Autowired Invite invite)
|
||||||
|
{
|
||||||
|
this.invite = invite;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
@@ -63,8 +72,8 @@ public class MessageInviteCommand implements MessageCommand
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
MessageEmbed inviteEmbed = Invite.generateEmbed();
|
MessageEmbed inviteEmbed = invite.generateEmbed();
|
||||||
Button inviteButton = Invite.getInviteButton();
|
Button inviteButton = invite.getInviteButton();
|
||||||
|
|
||||||
// if this is a guild, don't spam the invite in public but DM it
|
// if this is a guild, don't spam the invite in public but DM it
|
||||||
if (event.getChannelType().isGuild())
|
if (event.getChannelType().isGuild())
|
||||||
|
@@ -4,6 +4,8 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||||
@@ -13,8 +15,15 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageKickCommand implements MessageCommand
|
public class MessageKickCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final UserPunishment userPunishment;
|
||||||
|
|
||||||
|
public MessageKickCommand(@Autowired UserPunishment userPunishment)
|
||||||
|
{
|
||||||
|
this.userPunishment = userPunishment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
@@ -59,6 +68,6 @@ public class MessageKickCommand implements MessageCommand
|
|||||||
@Override
|
@Override
|
||||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||||
{
|
{
|
||||||
UserPunishment.handle(event, args, UserPunishment.PunishmentType.KICK);
|
userPunishment.handle(event, args, UserPunishment.PunishmentType.KICK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,8 @@ import net.dv8tion.jda.api.entities.User;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.HidekoBot;
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
import wtf.beatrice.hidekobot.commands.base.LoveCalculator;
|
import wtf.beatrice.hidekobot.commands.base.LoveCalculator;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
@@ -17,8 +19,15 @@ import java.util.Arrays;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageLoveCalculatorCommand implements MessageCommand
|
public class MessageLoveCalculatorCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final LoveCalculator loveCalculator;
|
||||||
|
|
||||||
|
public MessageLoveCalculatorCommand(@Autowired LoveCalculator loveCalculator)
|
||||||
|
{
|
||||||
|
this.loveCalculator = loveCalculator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,7 +100,7 @@ public class MessageLoveCalculatorCommand implements MessageCommand
|
|||||||
user2 = HidekoBot.getAPI().retrieveUserById(mentionedUserId).complete();
|
user2 = HidekoBot.getAPI().retrieveUserById(mentionedUserId).complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageEmbed embed = LoveCalculator.buildEmbedAndCacheResult(event.getAuthor(), user1, user2);
|
MessageEmbed embed = loveCalculator.buildEmbedAndCacheResult(event.getAuthor(), user1, user2);
|
||||||
event.getChannel().sendMessageEmbeds(embed).queue();
|
event.getChannel().sendMessageEmbeds(embed).queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,8 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.MagicBall;
|
import wtf.beatrice.hidekobot.commands.base.MagicBall;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||||
@@ -11,13 +13,20 @@ import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageMagicBallCommand implements MessageCommand
|
public class MessageMagicBallCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final MagicBall magicBall;
|
||||||
|
|
||||||
|
public MessageMagicBallCommand(@Autowired MagicBall magicBall)
|
||||||
|
{
|
||||||
|
this.magicBall = magicBall;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
{
|
{
|
||||||
return MagicBall.getLabels();
|
return magicBall.getLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -75,6 +84,6 @@ public class MessageMagicBallCommand implements MessageCommand
|
|||||||
String question = questionBuilder.toString();
|
String question = questionBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
event.getChannel().sendMessageEmbeds(MagicBall.generateEmbed(question, event.getAuthor())).queue();
|
event.getChannel().sendMessageEmbeds(magicBall.generateEmbed(question, event.getAuthor())).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@ import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.Say;
|
import wtf.beatrice.hidekobot.commands.base.Say;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||||
@@ -13,9 +15,16 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageSayCommand implements MessageCommand
|
public class MessageSayCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final Say say;
|
||||||
|
|
||||||
|
public MessageSayCommand(@Autowired Say say)
|
||||||
|
{
|
||||||
|
this.say = say;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
@@ -27,7 +36,7 @@ public class MessageSayCommand implements MessageCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<Permission> getPermissions()
|
public List<Permission> getPermissions()
|
||||||
{
|
{
|
||||||
return Collections.singletonList(Say.getPermission());
|
return Collections.singletonList(say.getPermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -4,6 +4,8 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||||
@@ -13,8 +15,15 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class MessageTimeoutCommand implements MessageCommand
|
public class MessageTimeoutCommand implements MessageCommand
|
||||||
{
|
{
|
||||||
|
private final UserPunishment userPunishment;
|
||||||
|
|
||||||
|
public MessageTimeoutCommand(@Autowired UserPunishment userPunishment)
|
||||||
|
{
|
||||||
|
this.userPunishment = userPunishment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedList<String> getCommandLabels()
|
public LinkedList<String> getCommandLabels()
|
||||||
@@ -59,6 +68,6 @@ public class MessageTimeoutCommand implements MessageCommand
|
|||||||
@Override
|
@Override
|
||||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||||
{
|
{
|
||||||
UserPunishment.handle(event, args, UserPunishment.PunishmentType.TIMEOUT);
|
userPunishment.handle(event, args, UserPunishment.PunishmentType.TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,12 +7,21 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashAvatarCommand extends SlashCommandImpl
|
public class SlashAvatarCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final ProfileImage profileImage;
|
||||||
|
|
||||||
|
public SlashAvatarCommand(@NotNull ProfileImage profileImage)
|
||||||
|
{
|
||||||
|
this.profileImage = profileImage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
@@ -44,13 +53,13 @@ public class SlashAvatarCommand extends SlashCommandImpl
|
|||||||
OptionMapping sizeArg = event.getOption("size");
|
OptionMapping sizeArg = event.getOption("size");
|
||||||
if (sizeArg != null)
|
if (sizeArg != null)
|
||||||
{
|
{
|
||||||
resolution = ProfileImage.parseResolution(sizeArg.getAsInt());
|
resolution = profileImage.parseResolution(sizeArg.getAsInt());
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
resolution = ProfileImage.parseResolution(512);
|
resolution = profileImage.parseResolution(512);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageResponse response = ProfileImage.buildResponse(resolution, user, ProfileImage.ImageType.AVATAR);
|
MessageResponse response = profileImage.buildResponse(resolution, user, ProfileImage.ImageType.AVATAR);
|
||||||
if (response.content() != null)
|
if (response.content() != null)
|
||||||
{
|
{
|
||||||
event.getHook().editOriginal(response.content()).queue();
|
event.getHook().editOriginal(response.content()).queue();
|
||||||
|
@@ -7,11 +7,21 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashBanCommand extends SlashCommandImpl
|
public class SlashBanCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final UserPunishment userPunishment;
|
||||||
|
|
||||||
|
public SlashBanCommand(@Autowired UserPunishment userPunishment)
|
||||||
|
{
|
||||||
|
this.userPunishment = userPunishment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
@@ -31,6 +41,6 @@ public class SlashBanCommand extends SlashCommandImpl
|
|||||||
@Override
|
@Override
|
||||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
||||||
{
|
{
|
||||||
UserPunishment.handle(event, UserPunishment.PunishmentType.BAN);
|
userPunishment.handle(event, UserPunishment.PunishmentType.BAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,12 +7,21 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashBannerCommand extends SlashCommandImpl
|
public class SlashBannerCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final ProfileImage profileImage;
|
||||||
|
|
||||||
|
public SlashBannerCommand(@NotNull ProfileImage profileImage)
|
||||||
|
{
|
||||||
|
this.profileImage = profileImage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
@@ -44,13 +53,13 @@ public class SlashBannerCommand extends SlashCommandImpl
|
|||||||
OptionMapping sizeArg = event.getOption("size");
|
OptionMapping sizeArg = event.getOption("size");
|
||||||
if (sizeArg != null)
|
if (sizeArg != null)
|
||||||
{
|
{
|
||||||
resolution = ProfileImage.parseResolution(sizeArg.getAsInt());
|
resolution = profileImage.parseResolution(sizeArg.getAsInt());
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
resolution = ProfileImage.parseResolution(512);
|
resolution = profileImage.parseResolution(512);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageResponse response = ProfileImage.buildResponse(resolution, user, ProfileImage.ImageType.BANNER);
|
MessageResponse response = profileImage.buildResponse(resolution, user, ProfileImage.ImageType.BANNER);
|
||||||
if (response.content() != null)
|
if (response.content() != null)
|
||||||
{
|
{
|
||||||
event.getHook().editOriginal(response.content()).queue();
|
event.getHook().editOriginal(response.content()).queue();
|
||||||
|
@@ -9,20 +9,29 @@ import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.commands.base.ClearChat;
|
import wtf.beatrice.hidekobot.commands.base.ClearChat;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashClearCommand extends SlashCommandImpl
|
public class SlashClearCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final ClearChat clearChat;
|
||||||
|
|
||||||
|
public SlashClearCommand(@Autowired ClearChat clearChat)
|
||||||
|
{
|
||||||
|
this.clearChat = clearChat;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
return Commands.slash(ClearChat.getLabel(),
|
return Commands.slash(clearChat.getLabel(),
|
||||||
ClearChat.getDescription())
|
clearChat.getDescription())
|
||||||
.addOption(OptionType.INTEGER, "amount", "The amount of messages to delete.")
|
.addOption(OptionType.INTEGER, "amount", "The amount of messages to delete.")
|
||||||
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(ClearChat.getPermission()));
|
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(clearChat.getPermission()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -32,7 +41,7 @@ public class SlashClearCommand extends SlashCommandImpl
|
|||||||
event.deferReply().queue();
|
event.deferReply().queue();
|
||||||
|
|
||||||
// check if user is trying to run command in dms.
|
// check if user is trying to run command in dms.
|
||||||
String error = ClearChat.checkDMs(event.getChannel());
|
String error = clearChat.checkDMs(event.getChannel());
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
event.getHook().editOriginal(error).queue();
|
event.getHook().editOriginal(error).queue();
|
||||||
@@ -46,9 +55,9 @@ public class SlashClearCommand extends SlashCommandImpl
|
|||||||
int toDeleteAmount = amountOption == null ? 1 : amountOption.getAsInt();
|
int toDeleteAmount = amountOption == null ? 1 : amountOption.getAsInt();
|
||||||
|
|
||||||
// cap the amount to avoid abuse.
|
// cap the amount to avoid abuse.
|
||||||
if (toDeleteAmount > ClearChat.getMaxAmount()) toDeleteAmount = 0;
|
if (toDeleteAmount > clearChat.getMaxAmount()) toDeleteAmount = 0;
|
||||||
|
|
||||||
error = ClearChat.checkDeleteAmount(toDeleteAmount);
|
error = clearChat.checkDeleteAmount(toDeleteAmount);
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
event.getHook().editOriginal(error).queue();
|
event.getHook().editOriginal(error).queue();
|
||||||
@@ -60,15 +69,15 @@ public class SlashClearCommand extends SlashCommandImpl
|
|||||||
Message botMessage = event.getHook().editOriginal(content).complete();
|
Message botMessage = event.getHook().editOriginal(content).complete();
|
||||||
|
|
||||||
// actually delete the messages.
|
// actually delete the messages.
|
||||||
int deleted = ClearChat.delete(toDeleteAmount,
|
int deleted = clearChat.delete(toDeleteAmount,
|
||||||
event.getInteraction().getIdLong(),
|
event.getInteraction().getIdLong(),
|
||||||
event.getChannel());
|
event.getChannel());
|
||||||
|
|
||||||
// get a nicely formatted message that logs the deletion of messages.
|
// get a nicely formatted message that logs the deletion of messages.
|
||||||
content = ClearChat.parseAmount(deleted);
|
content = clearChat.parseAmount(deleted);
|
||||||
|
|
||||||
// edit the message text and attach a button.
|
// edit the message text and attach a button.
|
||||||
Button dismiss = ClearChat.getDismissButton();
|
Button dismiss = clearChat.getDismissButton();
|
||||||
botMessage = botMessage.editMessage(content).setActionRow(dismiss).complete();
|
botMessage = botMessage.editMessage(content).setActionRow(dismiss).complete();
|
||||||
|
|
||||||
// add the message to database.
|
// add the message to database.
|
||||||
|
@@ -4,11 +4,20 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.CoinFlip;
|
import wtf.beatrice.hidekobot.commands.base.CoinFlip;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashCoinFlipCommand extends SlashCommandImpl
|
public class SlashCoinFlipCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final CoinFlip coinFlip;
|
||||||
|
|
||||||
|
public SlashCoinFlipCommand(@Autowired CoinFlip coinFlip)
|
||||||
|
{
|
||||||
|
this.coinFlip = coinFlip;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
@@ -21,14 +30,14 @@ public class SlashCoinFlipCommand extends SlashCommandImpl
|
|||||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
||||||
{
|
{
|
||||||
// perform coin flip
|
// perform coin flip
|
||||||
event.reply(CoinFlip.genRandom())
|
event.reply(coinFlip.genRandom())
|
||||||
.addActionRow(CoinFlip.getReflipButton())
|
.addActionRow(coinFlip.getReflipButton())
|
||||||
.queue((interaction) ->
|
.queue((interaction) ->
|
||||||
{
|
{
|
||||||
// set the command as expiring and restrict it to the user who ran it
|
// set the command as expiring and restrict it to the user who ran it
|
||||||
interaction.retrieveOriginal().queue((message) ->
|
interaction.retrieveOriginal().queue((message) ->
|
||||||
{
|
{
|
||||||
CoinFlip.trackAndRestrict(message, event.getUser());
|
coinFlip.trackAndRestrict(message, event.getUser());
|
||||||
}, (error) -> {
|
}, (error) -> {
|
||||||
});
|
});
|
||||||
}, (error) -> {
|
}, (error) -> {
|
||||||
|
@@ -6,12 +6,21 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.DiceRoll;
|
import wtf.beatrice.hidekobot.commands.base.DiceRoll;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashDiceRollCommand extends SlashCommandImpl
|
public class SlashDiceRollCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final DiceRoll diceRoll;
|
||||||
|
|
||||||
|
public SlashDiceRollCommand(@NotNull DiceRoll diceRoll)
|
||||||
|
{
|
||||||
|
this.diceRoll = diceRoll;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
@@ -37,7 +46,7 @@ public class SlashDiceRollCommand extends SlashCommandImpl
|
|||||||
|
|
||||||
String[] args = messageContent.split("\\s");
|
String[] args = messageContent.split("\\s");
|
||||||
|
|
||||||
MessageResponse response = DiceRoll.buildResponse(event.getUser(), args);
|
MessageResponse response = diceRoll.buildResponse(event.getUser(), args);
|
||||||
|
|
||||||
if (response.content() != null)
|
if (response.content() != null)
|
||||||
{
|
{
|
||||||
|
@@ -10,11 +10,19 @@ import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
|||||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
|
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
|
||||||
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
|
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.Invite;
|
import wtf.beatrice.hidekobot.commands.base.Invite;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashInviteCommand extends SlashCommandImpl
|
public class SlashInviteCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final Invite invite;
|
||||||
|
|
||||||
|
public SlashInviteCommand(@NotNull Invite invite)
|
||||||
|
{
|
||||||
|
this.invite = invite;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
@@ -36,8 +44,8 @@ public class SlashInviteCommand extends SlashCommandImpl
|
|||||||
}
|
}
|
||||||
replyCallbackAction.queue();
|
replyCallbackAction.queue();
|
||||||
|
|
||||||
MessageEmbed inviteEmbed = Invite.generateEmbed();
|
MessageEmbed inviteEmbed = invite.generateEmbed();
|
||||||
Button inviteButton = Invite.getInviteButton();
|
Button inviteButton = invite.getInviteButton();
|
||||||
|
|
||||||
WebhookMessageEditAction<Message> reply =
|
WebhookMessageEditAction<Message> reply =
|
||||||
event.getHook()
|
event.getHook()
|
||||||
|
@@ -7,11 +7,22 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashKickCommand extends SlashCommandImpl
|
public class SlashKickCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final UserPunishment userPunishment;
|
||||||
|
|
||||||
|
public SlashKickCommand(@Autowired UserPunishment userPunishment)
|
||||||
|
{
|
||||||
|
this.userPunishment = userPunishment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
@@ -31,6 +42,6 @@ public class SlashKickCommand extends SlashCommandImpl
|
|||||||
@Override
|
@Override
|
||||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
||||||
{
|
{
|
||||||
UserPunishment.handle(event, UserPunishment.PunishmentType.KICK);
|
userPunishment.handle(event, UserPunishment.PunishmentType.KICK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,11 +8,20 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.LoveCalculator;
|
import wtf.beatrice.hidekobot.commands.base.LoveCalculator;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashLoveCalculatorCommand extends SlashCommandImpl
|
public class SlashLoveCalculatorCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final LoveCalculator loveCalculator;
|
||||||
|
|
||||||
|
public SlashLoveCalculatorCommand(@NotNull LoveCalculator loveCalculator)
|
||||||
|
{
|
||||||
|
this.loveCalculator = loveCalculator;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
@@ -57,7 +66,7 @@ public class SlashLoveCalculatorCommand extends SlashCommandImpl
|
|||||||
secondUser = event.getUser();
|
secondUser = event.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageEmbed embed = LoveCalculator.buildEmbedAndCacheResult(event.getUser(), firstUser, secondUser);
|
MessageEmbed embed = loveCalculator.buildEmbedAndCacheResult(event.getUser(), firstUser, secondUser);
|
||||||
event.replyEmbeds(embed).queue();
|
event.replyEmbeds(embed).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,16 +7,25 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.MagicBall;
|
import wtf.beatrice.hidekobot.commands.base.MagicBall;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashMagicBallCommand extends SlashCommandImpl
|
public class SlashMagicBallCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final MagicBall magicBall;
|
||||||
|
|
||||||
|
public SlashMagicBallCommand(@NotNull MagicBall magicBall)
|
||||||
|
{
|
||||||
|
this.magicBall = magicBall;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
|
|
||||||
return Commands.slash(MagicBall.getLabels().get(0),
|
return Commands.slash(magicBall.getLabels().get(0),
|
||||||
"Ask a question to the magic ball.")
|
"Ask a question to the magic ball.")
|
||||||
.addOption(OptionType.STRING, "question",
|
.addOption(OptionType.STRING, "question",
|
||||||
"The question to ask.",
|
"The question to ask.",
|
||||||
@@ -43,7 +52,7 @@ public class SlashMagicBallCommand extends SlashCommandImpl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageEmbed response = MagicBall.generateEmbed(question, event.getUser());
|
MessageEmbed response = magicBall.generateEmbed(question, event.getUser());
|
||||||
event.replyEmbeds(response).queue();
|
event.replyEmbeds(response).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,11 +8,20 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.Say;
|
import wtf.beatrice.hidekobot.commands.base.Say;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashSayCommand extends SlashCommandImpl
|
public class SlashSayCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
private final Say say;
|
||||||
|
|
||||||
|
public SlashSayCommand(@NotNull Say say)
|
||||||
|
{
|
||||||
|
this.say = say;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
@@ -22,7 +31,7 @@ public class SlashSayCommand extends SlashCommandImpl
|
|||||||
"The message to send.",
|
"The message to send.",
|
||||||
true,
|
true,
|
||||||
false)
|
false)
|
||||||
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Say.getPermission()));
|
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(say.getPermission()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -7,11 +7,22 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
|
||||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class SlashTimeoutCommand extends SlashCommandImpl
|
public class SlashTimeoutCommand extends SlashCommandImpl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private final UserPunishment userPunishment;
|
||||||
|
|
||||||
|
public SlashTimeoutCommand(@Autowired UserPunishment userPunishment)
|
||||||
|
{
|
||||||
|
this.userPunishment = userPunishment;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getSlashCommandData()
|
public CommandData getSlashCommandData()
|
||||||
{
|
{
|
||||||
@@ -35,6 +46,6 @@ public class SlashTimeoutCommand extends SlashCommandImpl
|
|||||||
@Override
|
@Override
|
||||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
||||||
{
|
{
|
||||||
UserPunishment.handle(event, UserPunishment.PunishmentType.TIMEOUT);
|
userPunishment.handle(event, UserPunishment.PunishmentType.TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
|||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import wtf.beatrice.hidekobot.commands.base.CoinFlip;
|
import wtf.beatrice.hidekobot.commands.base.CoinFlip;
|
||||||
import wtf.beatrice.hidekobot.commands.base.Trivia;
|
import wtf.beatrice.hidekobot.commands.base.Trivia;
|
||||||
@@ -16,10 +17,13 @@ public class ButtonInteractionListener extends ListenerAdapter
|
|||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ButtonInteractionListener.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ButtonInteractionListener.class);
|
||||||
|
|
||||||
private final CommandService commandService;
|
private final CommandService commandService;
|
||||||
|
private final CoinFlip coinFlip;
|
||||||
|
|
||||||
public ButtonInteractionListener(CommandService commandService)
|
public ButtonInteractionListener(@Autowired CommandService commandService,
|
||||||
|
@Autowired CoinFlip coinFlip)
|
||||||
{
|
{
|
||||||
this.commandService = commandService;
|
this.commandService = commandService;
|
||||||
|
this.coinFlip = coinFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -30,7 +34,7 @@ public class ButtonInteractionListener extends ListenerAdapter
|
|||||||
{
|
{
|
||||||
|
|
||||||
// coinflip
|
// coinflip
|
||||||
case "coinflip_reflip" -> CoinFlip.buttonReFlip(event);
|
case "coinflip_reflip" -> coinFlip.buttonReFlip(event);
|
||||||
|
|
||||||
// generic dismiss button
|
// generic dismiss button
|
||||||
case "generic_dismiss" -> commandService.deleteUserLinkedMessage(event);
|
case "generic_dismiss" -> commandService.deleteUserLinkedMessage(event);
|
||||||
|
Reference in New Issue
Block a user