Compare commits

..

No commits in common. "0762068465cfefcadc51d8235906d3b5005205d4" and "19e3cde7e6fbcff41017e21e75e155e0dac640d4" have entirely different histories.

16 changed files with 14 additions and 266 deletions

View File

@ -1,23 +0,0 @@
package wtf.beatrice.hidekobot.commands.base;
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
import java.util.LinkedList;
public class Alias
{
public static String generateNiceAliases(MessageCommand command)
{
LinkedList<String> aliases = command.getCommandLabels();
StringBuilder aliasesStringBuilder = new StringBuilder();
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
}
return aliasesStringBuilder.toString();
}
}

View File

@ -5,7 +5,6 @@ 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.commands.base.Alias;
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
@ -38,18 +37,6 @@ public class AliasCommand implements MessageCommand
return CommandCategory.TOOLS;
}
@NotNull
@Override
public String getDescription() {
return "See other command aliases.";
}
@Nullable
@Override
public String getUsage() {
return "<command>";
}
@Override
public void runCommand(MessageReceivedEvent event, String label, String[] args)
{
@ -67,11 +54,19 @@ public class AliasCommand implements MessageCommand
return;
}
String aliases = Alias.generateNiceAliases(command);
aliases = "Aliases for **" + command.getCommandLabels().get(0) + "**: " + aliases;
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(aliases)
.reply(aliasesStringBuilder.toString())
.queue();
}

View File

@ -36,18 +36,6 @@ public class AvatarCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Get someone's avatar, or your own. You can additionally specify a resolution.";
}
@Nullable
@Override
public String getUsage() {
return "[mentioned user] [resolution]";
}
@NotNull
@Override
public CommandCategory getCategory() {
@ -59,7 +47,7 @@ public class AvatarCommand implements MessageCommand
{
int[] acceptedSizes = Cache.getSupportedAvatarResolutions();
User user;
User user = null;
int resolution = -1;
// we have no specific order for user and resolution, so let's try parsing any arg as resolution

View File

@ -33,18 +33,6 @@ public class BotInfoCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Get general info about the bot.";
}
@Nullable
@Override
public String getUsage() {
return null;
}
@NotNull
@Override
public CommandCategory getCategory() {

View File

@ -5,7 +5,6 @@ import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import wtf.beatrice.hidekobot.Cache;
import wtf.beatrice.hidekobot.commands.base.ClearChat;
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
@ -30,25 +29,12 @@ public class ClearCommand implements MessageCommand
public boolean passRawArgs() {
return false;
}
@NotNull
@Override
public CommandCategory getCategory() {
return CommandCategory.MODERATION;
}
@NotNull
@Override
public String getDescription() {
return "Clear the current channel's chat history.";
}
@Nullable
@Override
public String getUsage() {
return "[amount]";
}
@Override
public void runCommand(MessageReceivedEvent event, String label, String[] args)
{

View File

@ -31,18 +31,6 @@ public class CoinFlipCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Flip a coin.";
}
@Nullable
@Override
public String getUsage() {
return null;
}
@NotNull
@Override
public CommandCategory getCategory() {

View File

@ -30,23 +30,6 @@ public class DiceRollCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Roll dice. You can roll multiple dice at the same time." +
"\nExamples:" +
"\n - `d8 10` to roll an 8-sided die 10 times." +
"\n - `d12 3 d5 10` to roll a 12-sided die 3 times, and then a 5-sided die 10 times." +
"\n - `30` to roll a standard 6-sided die 30 times." +
"\n - `d10` to roll a 10-sided die once.";
}
@Nullable
@Override
public String getUsage() {
return "[dice size] [rolls]";
}
@NotNull
@Override
public CommandCategory getCategory() {

View File

@ -3,7 +3,6 @@ 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.objects.commands.CommandCategory;
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
@ -27,18 +26,6 @@ public class HelloCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Get pinged by the bot.";
}
@Nullable
@Override
public String getUsage() {
return null;
}
@NotNull
@Override
public CommandCategory getCategory() {

View File

@ -7,7 +7,6 @@ import org.apache.commons.text.WordUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import wtf.beatrice.hidekobot.Cache;
import wtf.beatrice.hidekobot.commands.base.Alias;
import wtf.beatrice.hidekobot.commands.base.Say;
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
@ -35,18 +34,6 @@ public class HelpCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Get general help on the bot. Specify a command if you want specific help about that command.";
}
@Nullable
@Override
public String getUsage() {
return "[command]";
}
@NotNull
@Override
public CommandCategory getCategory() {
@ -104,51 +91,6 @@ public class HelpCommand implements MessageCommand
embedBuilder.addField(niceCategoryName, commandsList.toString(), false);
}
event.getMessage().replyEmbeds(embedBuilder.build()).queue();
} else {
String commandLabel = args[0].toLowerCase();
MessageCommand command = Cache.getMessageCommandListener().getRegisteredCommand(commandLabel);
if(command == null)
{
event.getMessage().reply("Unrecognized command: `" + commandLabel + "`!").queue(); // todo prettier
return;
}
commandLabel = command.getCommandLabels().get(0);
String usage = "`" + Cache.getBotPrefix() + " " + commandLabel;
String internalUsage = command.getUsage();
if(internalUsage != null) usage += " " + internalUsage;
usage += "`";
String aliases = Alias.generateNiceAliases(command);
List<Permission> permissions = command.getPermissions();
StringBuilder permissionsStringBuilder = new StringBuilder();
if(permissions == null)
{
permissionsStringBuilder = new StringBuilder("Available to everyone");
} else {
for(int i = 0; i < permissions.size(); i++)
{
Permission permission = permissions.get(i);
permissionsStringBuilder.append("`").append(permission.getName()).append("`");
if(i + 1 != permissions.size())
permissionsStringBuilder.append(", "); // separate with comma expect on last iteration
}
}
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setColor(Cache.getBotColor());
embedBuilder.setTitle(WordUtils.capitalizeFully(commandLabel + " help"));
embedBuilder.addField("Description", command.getDescription(), false);
embedBuilder.addField("Usage", usage, false);
embedBuilder.addField("Aliases", aliases, false);
embedBuilder.addField("Permissions", permissionsStringBuilder.toString(), false);
event.getMessage().replyEmbeds(embedBuilder.build()).queue();
}
}

View File

@ -34,18 +34,6 @@ public class InviteCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Get the bot's invite link.";
}
@Nullable
@Override
public String getUsage() {
return null;
}
@NotNull
@Override
public CommandCategory getCategory() {

View File

@ -39,18 +39,6 @@ public class LoveCalculatorCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Calculate how much two people love each other. You can mention two people or just one.";
}
@Nullable
@Override
public String getUsage() {
return "<person 1> [person 2]";
}
@NotNull
@Override
public CommandCategory getCategory() {
@ -67,9 +55,7 @@ public class LoveCalculatorCommand implements MessageCommand
if(args.length == 0 || mentions.isEmpty())
{
event.getMessage()
.reply("\uD83D\uDE22 I need to know who to check! Please mention them.")
.queue();
event.getMessage().reply("\uD83D\uDE22 I need to know who to check!").queue();
return;
}

View File

@ -30,18 +30,6 @@ public class MagicBallCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Ask a question to the Magic Ball.";
}
@Nullable
@Override
public String getUsage() {
return "<question>";
}
@NotNull
@Override
public CommandCategory getCategory() {

View File

@ -30,18 +30,6 @@ public class SayCommand implements MessageCommand
return true;
}
@NotNull
@Override
public String getDescription() {
return "Make the bot say something for you.";
}
@Nullable
@Override
public String getUsage() {
return "<text>";
}
@NotNull
@Override
public CommandCategory getCategory() {

View File

@ -36,18 +36,6 @@ public class UrbanDictionaryCommand implements MessageCommand
return false;
}
@NotNull
@Override
public String getDescription() {
return "Look something up in the Urban Dictionary.";
}
@Nullable
@Override
public String getUsage() {
return "<query>";
}
@NotNull
@Override
public CommandCategory getCategory() {

View File

@ -7,7 +7,6 @@ import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;
import wtf.beatrice.hidekobot.Cache;
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
import wtf.beatrice.hidekobot.objects.comparators.MessageCommandAliasesComparator;
@ -81,9 +80,7 @@ public class MessageCommandListener extends ListenerAdapter
// it will be the whole text as a single element.
if(argsString.isEmpty())
{
event.getMessage()
.reply("Hello there! ✨ Type `" + Cache.getBotPrefix() + " help` to get started!")
.queue();
event.getMessage().reply("Hello there! ✨").queue();
return;
}
@ -96,11 +93,7 @@ public class MessageCommandListener extends ListenerAdapter
if(commandObject == null)
{
/* temporarily disabled because when people talk about the bot, it replies with this spammy message.
event.getMessage().reply("Unrecognized command: `" + commandLabel + "`!").queue(); // todo prettier
*/
return;
}

View File

@ -48,23 +48,6 @@ public interface MessageCommand
@NotNull
CommandCategory getCategory();
/**
* Say what this command does.
*
* @return a String explaining what this command does.
*/
@NotNull
String getDescription();
/**
* Say how people should use this command.
*
* @return a String explaining how to use the command, excluding the bot prefix and command name. Null if no parameter is needed
*/
@Nullable
String getUsage();
/**
* Run the command logic by parsing the event and replying accordingly.
*