Compare commits
3 Commits
9278b485d9
...
72f9bb4eb5
Author | SHA1 | Date | |
---|---|---|---|
72f9bb4eb5 | |||
407ca279f5 | |||
9eefa4b958 |
@ -131,6 +131,7 @@ public class HidekoBot
|
|||||||
// register message commands
|
// register message commands
|
||||||
MessageCommandListener messageCommandListener = new MessageCommandListener();
|
MessageCommandListener messageCommandListener = new MessageCommandListener();
|
||||||
messageCommandListener.registerCommand(new HelloCommand());
|
messageCommandListener.registerCommand(new HelloCommand());
|
||||||
|
messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.AliasCommand());
|
||||||
messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.AvatarCommand());
|
messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.AvatarCommand());
|
||||||
messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.BotInfoCommand());
|
messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.BotInfoCommand());
|
||||||
messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.CoinFlipCommand());
|
messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.CoinFlipCommand());
|
||||||
|
@ -16,7 +16,7 @@ public class MagicBall
|
|||||||
|
|
||||||
public static LinkedList<String> getLabels()
|
public static LinkedList<String> getLabels()
|
||||||
{
|
{
|
||||||
return new LinkedList<>(Arrays.asList("8ball", "eightball", "magicball", "8b"));
|
return new LinkedList<>(Arrays.asList("8ball", "8b", "eightball", "magicball"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static List<String> answers = new ArrayList<>(
|
private final static List<String> answers = new ArrayList<>(
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
package wtf.beatrice.hidekobot.commands.message;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||||
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AliasCommand implements MessageCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LinkedList<String> getCommandLabels() {
|
||||||
|
return new LinkedList<>(Arrays.asList("alias", "aliases"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public List<Permission> getPermissions() {
|
||||||
|
return null; // anyone can use it
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean passRawArgs() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public CommandCategory getCategory() {
|
||||||
|
return CommandCategory.TOOLS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||||
|
{
|
||||||
|
if(args.length == 0)
|
||||||
|
{
|
||||||
|
event.getMessage().reply("\uD83D\uDE20 Hey, you have to specify a command!").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String commandLabel = args[0].toLowerCase();
|
||||||
|
MessageCommand command = Cache.getMessageCommandListener().getRegisteredCommand(commandLabel);
|
||||||
|
if(command == null)
|
||||||
|
{
|
||||||
|
event.getMessage().reply("Unrecognized command: `" + commandLabel + "`!").queue(); // todo prettier
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LinkedList<String> aliases = command.getCommandLabels();
|
||||||
|
StringBuilder aliasesStringBuilder = new StringBuilder();
|
||||||
|
aliasesStringBuilder.append("Aliases for **").append(aliases.get(0)).append("**: ");
|
||||||
|
for(int i = 0; i < aliases.size(); i++)
|
||||||
|
{
|
||||||
|
aliasesStringBuilder.append("`").append(aliases.get(i)).append("`");
|
||||||
|
|
||||||
|
if(i + 1 != aliases.size())
|
||||||
|
aliasesStringBuilder.append(", "); // separate with comma except on last iteration
|
||||||
|
}
|
||||||
|
|
||||||
|
event.getMessage()
|
||||||
|
.reply(aliasesStringBuilder.toString())
|
||||||
|
.queue();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import net.dv8tion.jda.api.entities.Mentions;
|
|||||||
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 net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.HidekoBot;
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
@ -35,6 +36,7 @@ public class AvatarCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.TOOLS;
|
return CommandCategory.TOOLS;
|
||||||
|
@ -3,6 +3,7 @@ package wtf.beatrice.hidekobot.commands.message;
|
|||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.commands.base.BotInfo;
|
import wtf.beatrice.hidekobot.commands.base.BotInfo;
|
||||||
@ -32,6 +33,7 @@ public class BotInfoCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.TOOLS;
|
return CommandCategory.TOOLS;
|
||||||
|
@ -4,6 +4,7 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
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 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;
|
||||||
@ -28,6 +29,7 @@ public class ClearCommand implements MessageCommand
|
|||||||
public boolean passRawArgs() {
|
public boolean passRawArgs() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.MODERATION;
|
return CommandCategory.MODERATION;
|
||||||
|
@ -2,6 +2,7 @@ package wtf.beatrice.hidekobot.commands.message;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
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;
|
||||||
@ -30,6 +31,7 @@ public class CoinFlipCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.FUN;
|
return CommandCategory.FUN;
|
||||||
|
@ -3,6 +3,7 @@ package wtf.beatrice.hidekobot.commands.message;
|
|||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.Permission;
|
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.objects.Dice;
|
import wtf.beatrice.hidekobot.objects.Dice;
|
||||||
@ -29,6 +30,7 @@ public class DiceRollCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.FUN;
|
return CommandCategory.FUN;
|
||||||
|
@ -2,6 +2,7 @@ package wtf.beatrice.hidekobot.commands.message;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
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 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;
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ public class HelloCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.FUN;
|
return CommandCategory.FUN;
|
||||||
|
@ -4,6 +4,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
|
|||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.apache.commons.text.WordUtils;
|
import org.apache.commons.text.WordUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.commands.base.Say;
|
import wtf.beatrice.hidekobot.commands.base.Say;
|
||||||
@ -33,6 +34,7 @@ public class HelpCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.TOOLS;
|
return CommandCategory.TOOLS;
|
||||||
|
@ -5,6 +5,7 @@ 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.events.message.MessageReceivedEvent;
|
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
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;
|
||||||
@ -33,6 +34,7 @@ public class InviteCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.FUN;
|
return CommandCategory.FUN;
|
||||||
|
@ -6,6 +6,7 @@ import net.dv8tion.jda.api.entities.IMentionable;
|
|||||||
import net.dv8tion.jda.api.entities.Mentions;
|
import net.dv8tion.jda.api.entities.Mentions;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
import wtf.beatrice.hidekobot.Cache;
|
||||||
import wtf.beatrice.hidekobot.HidekoBot;
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
@ -38,6 +39,7 @@ public class LoveCalculatorCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.FUN;
|
return CommandCategory.FUN;
|
||||||
|
@ -2,6 +2,7 @@ package wtf.beatrice.hidekobot.commands.message;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
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;
|
||||||
@ -29,6 +30,7 @@ public class MagicBallCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.FUN;
|
return CommandCategory.FUN;
|
||||||
|
@ -2,6 +2,7 @@ package wtf.beatrice.hidekobot.commands.message;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
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;
|
||||||
@ -29,6 +30,7 @@ public class SayCommand implements MessageCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.TOOLS;
|
return CommandCategory.TOOLS;
|
||||||
|
@ -4,6 +4,7 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
@ -35,6 +36,7 @@ public class UrbanDictionaryCommand implements MessageCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CommandCategory getCategory() {
|
public CommandCategory getCategory() {
|
||||||
return CommandCategory.FUN;
|
return CommandCategory.FUN;
|
||||||
|
@ -2,6 +2,7 @@ package wtf.beatrice.hidekobot.objects.commands;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
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.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -44,6 +45,7 @@ public interface MessageCommand
|
|||||||
*
|
*
|
||||||
* @return the command category.
|
* @return the command category.
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
CommandCategory getCategory();
|
CommandCategory getCategory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user