Class CoreSlashCommandHandler
java.lang.Object
net.dv8tion.jda.api.hooks.ListenerAdapter
io.github.yusufsdiscordbot.yusufsdiscordcore.bot.handlers.CoreSlashCommandHandler
- All Implemented Interfaces:
net.dv8tion.jda.api.hooks.EventListener
- Direct Known Subclasses:
ExampleCommandHandler
@Authors(namesOfTheAuthors={"Yusuf Arfan Ismail","Serkwi Bruno Ndzi"},
namesOfTheAuthorsGithub={"RealYusufIsmail","nDZIB"})
public abstract class CoreSlashCommandHandler
extends net.dv8tion.jda.api.hooks.ListenerAdapter
For register the commands make sure to set it to awaitReady as seen here
jda.awaitReady()
.addEventListener(new CommandHandler(jda, jda.getGuildById(872494635757473932L)));
The is class which process the registration of the commands.
Commands are register by using a List with an example for registering slash commands being
ListIn oder to do other you can do on of the following:handler = new ArrayList<>();
handler.add(new ExampleCommand());
queueAndRegisterSlashCommands(handler);
//slash command
List slashCommand = new ArrayList<>();
//User Command
List userCommand = new ArrayList<>();
//Message Command
List messageCommand = new ArrayList<>();
slashCommand.add(new ExampleCommand());
queueAndRegisterCommands(slashCommand, userCommand, messageCommand);
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCoreSlashCommandHandler(@NotNull net.dv8tion.jda.api.JDA jda, @NotNull net.dv8tion.jda.api.entities.Guild guild) For an example please seeExampleCommandHandler(JDA, Guild) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract long@NotNull List<MessageCommand>Gets message commands as a list.@NotNull List<SlashCommand>Gets slash commands as a list.@NotNull List<UserCommand>Gets user commands as a list.voidonSlashCommandInteraction(@NotNull net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent slashCommandEvent) Handles the slash command event.voidqueueAndRegisterCommands(@NotNull Collection<SlashCommand> commands, @NotNull Collection<UserCommand> userCommands, @NotNull Collection<MessageCommand> messageCommands) Used to register the slash commands.voidqueueAndRegisterMessageContextCommands(@NotNull Collection<MessageCommand> messageCommand) Used to register the message context commands.voidqueueAndRegisterSlashCommands(@NotNull Collection<SlashCommand> slashCommands) Used to register the slash commands.voidqueueAndRegisterUserCommands(@NotNull Collection<UserCommand> userCommands) Used to register the user commands.Methods inherited from class net.dv8tion.jda.api.hooks.ListenerAdapter
onButtonInteraction, onChannelCreate, onChannelDelete, onChannelUpdateArchived, onChannelUpdateArchiveTimestamp, onChannelUpdateAutoArchiveDuration, onChannelUpdateBitrate, onChannelUpdateInvitable, onChannelUpdateLocked, onChannelUpdateName, onChannelUpdateNSFW, onChannelUpdateParent, onChannelUpdatePosition, onChannelUpdateRegion, onChannelUpdateSlowmode, onChannelUpdateTopic, onChannelUpdateType, onChannelUpdateUserLimit, onCommandAutoCompleteInteraction, onDisconnect, onEmoteAdded, onEmoteRemoved, onEmoteUpdateName, onEmoteUpdateRoles, onEvent, onException, onGatewayPing, onGenericAutoCompleteInteraction, onGenericChannel, onGenericChannelUpdate, onGenericCommandInteraction, onGenericComponentInteractionCreate, onGenericContextInteraction, onGenericEmote, onGenericEmoteUpdate, onGenericEvent, onGenericGuild, onGenericGuildInvite, onGenericGuildMember, onGenericGuildMemberUpdate, onGenericGuildUpdate, onGenericGuildVoice, onGenericInteractionCreate, onGenericMessage, onGenericMessageReaction, onGenericPermissionOverride, onGenericRole, onGenericRoleUpdate, onGenericSelfUpdate, onGenericStageInstance, onGenericStageInstanceUpdate, onGenericThread, onGenericThreadMember, onGenericUpdate, onGenericUser, onGenericUserPresence, onGuildAvailable, onGuildBan, onGuildInviteCreate, onGuildInviteDelete, onGuildJoin, onGuildLeave, onGuildMemberJoin, onGuildMemberRemove, onGuildMemberRoleAdd, onGuildMemberRoleRemove, onGuildMemberUpdate, onGuildMemberUpdateAvatar, onGuildMemberUpdateBoostTime, onGuildMemberUpdateNickname, onGuildMemberUpdatePending, onGuildMemberUpdateTimeOut, onGuildReady, onGuildTimeout, onGuildUnavailable, onGuildUnban, onGuildUpdateAfkChannel, onGuildUpdateAfkTimeout, onGuildUpdateBanner, onGuildUpdateBoostCount, onGuildUpdateBoostTier, onGuildUpdateCommunityUpdatesChannel, onGuildUpdateDescription, onGuildUpdateExplicitContentLevel, onGuildUpdateFeatures, onGuildUpdateIcon, onGuildUpdateLocale, onGuildUpdateMaxMembers, onGuildUpdateMaxPresences, onGuildUpdateMFALevel, onGuildUpdateName, onGuildUpdateNotificationLevel, onGuildUpdateNSFWLevel, onGuildUpdateOwner, onGuildUpdateRulesChannel, onGuildUpdateSplash, onGuildUpdateSystemChannel, onGuildUpdateVanityCode, onGuildUpdateVerificationLevel, onGuildVoiceDeafen, onGuildVoiceGuildDeafen, onGuildVoiceGuildMute, onGuildVoiceJoin, onGuildVoiceLeave, onGuildVoiceMove, onGuildVoiceMute, onGuildVoiceRequestToSpeak, onGuildVoiceSelfDeafen, onGuildVoiceSelfMute, onGuildVoiceStream, onGuildVoiceSuppress, onGuildVoiceUpdate, onGuildVoiceVideo, onHttpRequest, onMessageBulkDelete, onMessageContextInteraction, onMessageDelete, onMessageEmbed, onMessageReactionAdd, onMessageReactionRemove, onMessageReactionRemoveAll, onMessageReactionRemoveEmote, onMessageReceived, onMessageUpdate, onPermissionOverrideCreate, onPermissionOverrideDelete, onPermissionOverrideUpdate, onRawGateway, onReady, onReconnected, onResumed, onRoleCreate, onRoleDelete, onRoleUpdateColor, onRoleUpdateHoisted, onRoleUpdateIcon, onRoleUpdateMentionable, onRoleUpdateName, onRoleUpdatePermissions, onRoleUpdatePosition, onSelectMenuInteraction, onSelfUpdateAvatar, onSelfUpdateMFA, onSelfUpdateName, onSelfUpdateVerified, onShutdown, onStageInstanceCreate, onStageInstanceDelete, onStageInstanceUpdatePrivacyLevel, onStageInstanceUpdateTopic, onStatusChange, onThreadHidden, onThreadMemberJoin, onThreadMemberLeave, onThreadRevealed, onUnavailableGuildJoined, onUnavailableGuildLeave, onUserActivityEnd, onUserActivityStart, onUserContextInteraction, onUserTyping, onUserUpdateActivities, onUserUpdateActivityOrder, onUserUpdateAvatar, onUserUpdateDiscriminator, onUserUpdateFlags, onUserUpdateName, onUserUpdateOnlineStatus
-
Constructor Details
-
CoreSlashCommandHandler
protected CoreSlashCommandHandler(@NotNull @NotNull net.dv8tion.jda.api.JDA jda, @NotNull @NotNull net.dv8tion.jda.api.entities.Guild guild) For an example please seeExampleCommandHandler(JDA, Guild)
-
-
Method Details
-
botOwnerId
protected abstract long botOwnerId()- Returns:
- used to set the bot owner id.
-
queueAndRegisterCommands
public void queueAndRegisterCommands(@NotNull @NotNull Collection<SlashCommand> commands, @NotNull @NotNull Collection<UserCommand> userCommands, @NotNull @NotNull Collection<MessageCommand> messageCommands) Used to register the slash commands.- Parameters:
commands- The slash commands
-
queueAndRegisterUserCommands
Used to register the user commands.- Parameters:
userCommands- The user commands.
-
queueAndRegisterSlashCommands
Used to register the slash commands.- Parameters:
slashCommands- the slash commands.
-
queueAndRegisterMessageContextCommands
public void queueAndRegisterMessageContextCommands(@NotNull @NotNull Collection<MessageCommand> messageCommand) Used to register the message context commands.- Parameters:
messageCommand- the message context command.
-
onSlashCommandInteraction
public void onSlashCommandInteraction(@NotNull @NotNull net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent slashCommandEvent) Handles the slash command event.- Overrides:
onSlashCommandInteractionin classnet.dv8tion.jda.api.hooks.ListenerAdapter- Parameters:
slashCommandEvent- The original slash command event,
-
getSlashCommands
Gets slash commands as a list.- Returns:
- retrieves the commands as a list.
-
getUserCommands
Gets user commands as a list.- Returns:
- retrieves the commands as a list.
-
getMessageCommands
Gets message commands as a list.- Returns:
- retrieves the commands as a list.
-