Remove the need to register slash commands separately
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
We modified the slash command interface to allow getting command data, and created a generic implementation of it that automatically retrieves data from the command data. The interface should not be used now. Instead, extending the implementation is preferred as it provides a semi-working command already.
This commit is contained in:
@@ -1,18 +1,28 @@
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
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.Commands;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import wtf.beatrice.hidekobot.objects.SlashCommand;
|
||||
import wtf.beatrice.hidekobot.objects.SlashCommandImpl;
|
||||
|
||||
public class SayCommand implements SlashCommand
|
||||
public class SayCommand extends SlashCommandImpl
|
||||
{
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "say";
|
||||
public CommandData getSlashCommandData()
|
||||
{
|
||||
|
||||
return Commands.slash("say", "Make the bot say something.")
|
||||
.addOption(OptionType.STRING, "text",
|
||||
"The message to send.",
|
||||
true,
|
||||
false)
|
||||
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MESSAGE_MANAGE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user