java.lang.Object
net.dv8tion.jda.api.hooks.ListenerAdapter
io.github.yusufsdiscordbot.yusufsdiscordcore.bot.handlers.extensions.SlashCommand
All Implemented Interfaces:
net.dv8tion.jda.api.hooks.EventListener

public abstract class SlashCommand extends net.dv8tion.jda.api.hooks.ListenerAdapter
Used when making a new command. Imports all the need methods into a new class.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SlashCommand(String name, String description, boolean isGuildOnly, CommandType... commandType)
    Were the command is registered.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Used to determine whether the command is Global(can be used on all servers) or whether it is only a Guild command(can only be used in specific servers)
    Used to determine what type of command it is.
    final String
    Provides the user information on what the command is about.
    final String
    Provides the user with name of the command
    final @NotNull net.dv8tion.jda.api.interactions.commands.build.SlashCommandData
    Retrieves all the slash command data such as the name and description of the command.
    void
    onButtonInteraction(net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent event)
     
    void
    onSelectMenuInteraction(net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent event)
     
    abstract void
    Used when creating a new slash command.

    Methods inherited from class net.dv8tion.jda.api.hooks.ListenerAdapter

    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, onSelfUpdateAvatar, onSelfUpdateMFA, onSelfUpdateName, onSelfUpdateVerified, onShutdown, onSlashCommandInteraction, onStageInstanceCreate, onStageInstanceDelete, onStageInstanceUpdatePrivacyLevel, onStageInstanceUpdateTopic, onStatusChange, onThreadHidden, onThreadMemberJoin, onThreadMemberLeave, onThreadRevealed, onUnavailableGuildJoined, onUnavailableGuildLeave, onUserActivityEnd, onUserActivityStart, onUserContextInteraction, onUserTyping, onUserUpdateActivities, onUserUpdateActivityOrder, onUserUpdateAvatar, onUserUpdateDiscriminator, onUserUpdateFlags, onUserUpdateName, onUserUpdateOnlineStatus

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SlashCommand

      protected SlashCommand(@Nonnull String name, @Nonnull String description, boolean isGuildOnly, @Nonnull CommandType... commandType)
      Were the command is registered.
  • Method Details

    • getName

      @Nonnull public final String getName()
      Provides the user with name of the command
      Returns:
      CommandDataImpl.getName()
    • getDescription

      @Nonnull public final String getDescription()
      Provides the user information on what the command is about.
      Returns:
      CommandDataImpl.getDescription()
    • getSlashCommandData

      @NotNull public final @NotNull net.dv8tion.jda.api.interactions.commands.build.SlashCommandData getSlashCommandData()
      Retrieves all the slash command data such as the name and description of the command. Also
      Returns:
      Commands.slash(String, String) and can also return
      Choices can also be used which makes it easier for the user. which returns OptionData.addChoice(String, long)

    • checkIfIsGuildOnly

      public boolean checkIfIsGuildOnly()
      Used to determine whether the command is Global(can be used on all servers) or whether it is only a Guild command(can only be used in specific servers)
    • getCommandType

      public CommandType getCommandType()
      Used to determine what type of command it is.
      Returns:
      Must be one of the following:
    • onSlashCommand

      public abstract void onSlashCommand(@Nonnull YSlashCommandInteractionEvent yusufSlashCommandEvent)
      Used when creating a new slash command.
      Parameters:
      yusufSlashCommandEvent - the event that is being used to create the command.
    • onButtonInteraction

      public void onButtonInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent event)
      Overrides:
      onButtonInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
    • onSelectMenuInteraction

      public void onSelectMenuInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent event)
      Overrides:
      onSelectMenuInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter