Class InteractionHandler

java.lang.Object
net.dv8tion.jda.api.hooks.ListenerAdapter
xyz.dynxsty.dih4jda.InteractionHandler
All Implemented Interfaces:
net.dv8tion.jda.api.hooks.EventListener

public class InteractionHandler extends net.dv8tion.jda.api.hooks.ListenerAdapter
Handler class, that finds, registers and handles all Application Commands and their components.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static Map<String,net.dv8tion.jda.api.interactions.commands.Command>
    Returns an unmodifiable Map of all retrieved (and/or queued) commands, where the key is the commands' name and the value the Command instance itself.
    void
    onButtonInteraction(net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent event)
    Fired if Discord reports a ButtonInteractionEvent.
    void
    onCommandAutoCompleteInteraction(net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent event)
    Fired if Discord reports a CommandAutoCompleteInteractionEvent.
    void
    onEntitySelectInteraction(net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent event)
     
    void
    onMessageContextInteraction(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event)
    Fired if Discord reports a MessageContextInteractionEvent.
    void
    onModalInteraction(net.dv8tion.jda.api.events.interaction.ModalInteractionEvent event)
    Fired if Discord reports a ModalInteractionEvent.
    void
    onSlashCommandInteraction(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event)
    Fired if Discord reports a SlashCommandInteractionEvent.
    void
    onStringSelectInteraction(net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent event)
    Fired if Discord reports a StringSelectInteractionEvent.
    void
    onUserContextInteraction(net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent event)
    Fired if Discord reports a UserContextInteractionEvent.
    void
    Registers all interactions.

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

    onApplicationCommandUpdatePrivileges, onApplicationUpdatePrivileges, onAutoModExecution, onAutoModRuleCreate, onAutoModRuleDelete, onAutoModRuleUpdate, onChannelCreate, onChannelDelete, onChannelUpdateAppliedTags, onChannelUpdateArchived, onChannelUpdateArchiveTimestamp, onChannelUpdateAutoArchiveDuration, onChannelUpdateBitrate, onChannelUpdateDefaultLayout, onChannelUpdateDefaultReaction, onChannelUpdateDefaultSortOrder, onChannelUpdateDefaultThreadSlowmode, onChannelUpdateFlags, onChannelUpdateInvitable, onChannelUpdateLocked, onChannelUpdateName, onChannelUpdateNSFW, onChannelUpdateParent, onChannelUpdatePosition, onChannelUpdateRegion, onChannelUpdateSlowmode, onChannelUpdateTopic, onChannelUpdateType, onChannelUpdateUserLimit, onChannelUpdateVoiceStatus, onEmojiAdded, onEmojiRemoved, onEmojiUpdateName, onEmojiUpdateRoles, onEntitlementCreate, onEntitlementDelete, onEntitlementUpdate, onEvent, onException, onForumTagAdd, onForumTagRemove, onForumTagUpdateEmoji, onForumTagUpdateModerated, onForumTagUpdateName, onGatewayPing, onGenericAutoCompleteInteraction, onGenericAutoModRule, onGenericChannel, onGenericChannelUpdate, onGenericCommandInteraction, onGenericComponentInteractionCreate, onGenericContextInteraction, onGenericEmoji, onGenericEmojiUpdate, onGenericEntitlement, onGenericEvent, onGenericForumTag, onGenericForumTagUpdate, onGenericGuild, onGenericGuildInvite, onGenericGuildMember, onGenericGuildMemberUpdate, onGenericGuildSticker, onGenericGuildStickerUpdate, onGenericGuildUpdate, onGenericGuildVoice, onGenericInteractionCreate, onGenericMessage, onGenericMessagePollVote, onGenericMessageReaction, onGenericPermissionOverride, onGenericPrivilegeUpdate, onGenericRole, onGenericRoleUpdate, onGenericScheduledEventGateway, onGenericScheduledEventUpdate, onGenericScheduledEventUser, onGenericSelectMenuInteraction, onGenericSelfUpdate, onGenericSession, onGenericStageInstance, onGenericStageInstanceUpdate, onGenericThread, onGenericThreadMember, onGenericUpdate, onGenericUser, onGenericUserPresence, onGenericUserUpdate, onGuildAuditLogEntryCreate, onGuildAvailable, onGuildBan, onGuildInviteCreate, onGuildInviteDelete, onGuildJoin, onGuildLeave, onGuildMemberJoin, onGuildMemberRemove, onGuildMemberRoleAdd, onGuildMemberRoleRemove, onGuildMemberUpdate, onGuildMemberUpdateAvatar, onGuildMemberUpdateBoostTime, onGuildMemberUpdateFlags, onGuildMemberUpdateNickname, onGuildMemberUpdatePending, onGuildMemberUpdateTimeOut, onGuildReady, onGuildStickerAdded, onGuildStickerRemoved, onGuildStickerUpdateAvailable, onGuildStickerUpdateDescription, onGuildStickerUpdateName, onGuildStickerUpdateTags, 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, onGuildVoiceMute, onGuildVoiceRequestToSpeak, onGuildVoiceSelfDeafen, onGuildVoiceSelfMute, onGuildVoiceStream, onGuildVoiceSuppress, onGuildVoiceUpdate, onGuildVoiceVideo, onHttpRequest, onMessageBulkDelete, onMessageDelete, onMessagePollVoteAdd, onMessagePollVoteRemove, onMessageReactionAdd, onMessageReactionRemove, onMessageReactionRemoveAll, onMessageReactionRemoveEmoji, onMessageReceived, onMessageUpdate, onPermissionOverrideCreate, onPermissionOverrideDelete, onPermissionOverrideUpdate, onRawGateway, onReady, onRoleCreate, onRoleDelete, onRoleUpdateColor, onRoleUpdateHoisted, onRoleUpdateIcon, onRoleUpdateMentionable, onRoleUpdateName, onRoleUpdatePermissions, onRoleUpdatePosition, onScheduledEventCreate, onScheduledEventDelete, onScheduledEventUpdateDescription, onScheduledEventUpdateEndTime, onScheduledEventUpdateImage, onScheduledEventUpdateLocation, onScheduledEventUpdateName, onScheduledEventUpdateStartTime, onScheduledEventUpdateStatus, onScheduledEventUserAdd, onScheduledEventUserRemove, onSelfUpdateAvatar, onSelfUpdateDiscriminator, onSelfUpdateGlobalName, onSelfUpdateMFA, onSelfUpdateName, onSelfUpdateVerified, onSessionDisconnect, onSessionInvalidate, onSessionRecreate, onSessionResume, onShutdown, onStageInstanceCreate, onStageInstanceDelete, onStageInstanceUpdatePrivacyLevel, onStageInstanceUpdateTopic, onStatusChange, onThreadHidden, onThreadMemberJoin, onThreadMemberLeave, onThreadRevealed, onUnavailableGuildJoined, onUnavailableGuildLeave, onUserActivityEnd, onUserActivityStart, onUserTyping, onUserUpdateActivities, onUserUpdateActivityOrder, onUserUpdateAvatar, onUserUpdateDiscriminator, onUserUpdateFlags, onUserUpdateGlobalName, onUserUpdateName, onUserUpdateOnlineStatus

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getRetrievedCommands

      @Nonnull public static Map<String,net.dv8tion.jda.api.interactions.commands.Command> getRetrievedCommands()
      Returns an unmodifiable Map of all retrieved (and/or queued) commands, where the key is the commands' name and the value the Command instance itself. This map is empty if DIH4JDA.registerInteractions() wasn't called before.
      Returns:
      An immutable Map containing all global and guild commands.
    • registerInteractions

      public void registerInteractions()
      Registers all interactions. This method can be accessed from the DIH4JDA instance.
      This is automatically executed each time the ListenerAdapter.onReady(net.dv8tion.jda.api.events.session.ReadyEvent) event is executed. (can be disabled using DIH4JDABuilder.disableAutomaticCommandRegistration())
    • onSlashCommandInteraction

      public void onSlashCommandInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event)
      Fired if Discord reports a SlashCommandInteractionEvent.
      Overrides:
      onSlashCommandInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
      Parameters:
      event - The SlashCommandInteractionEvent that was fired.
    • onUserContextInteraction

      public void onUserContextInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent event)
      Fired if Discord reports a UserContextInteractionEvent.
      Overrides:
      onUserContextInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
      Parameters:
      event - The UserContextInteractionEvent that was fired.
    • onMessageContextInteraction

      public void onMessageContextInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event)
      Fired if Discord reports a MessageContextInteractionEvent.
      Overrides:
      onMessageContextInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
      Parameters:
      event - The MessageContextInteractionEvent that was fired.
    • onCommandAutoCompleteInteraction

      public void onCommandAutoCompleteInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent event)
      Fired if Discord reports a CommandAutoCompleteInteractionEvent.
      Overrides:
      onCommandAutoCompleteInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
      Parameters:
      event - The CommandAutoCompleteInteractionEvent that was fired.
    • onButtonInteraction

      public void onButtonInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent event)
      Fired if Discord reports a ButtonInteractionEvent.
      Overrides:
      onButtonInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
      Parameters:
      event - The ButtonInteractionEvent that was fired.
    • onStringSelectInteraction

      public void onStringSelectInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent event)
      Fired if Discord reports a StringSelectInteractionEvent.
      Overrides:
      onStringSelectInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
      Parameters:
      event - The StringSelectInteractionEvent that was fired.
    • onEntitySelectInteraction

      public void onEntitySelectInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent event)
      Overrides:
      onEntitySelectInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
    • onModalInteraction

      public void onModalInteraction(@Nonnull net.dv8tion.jda.api.events.interaction.ModalInteractionEvent event)
      Fired if Discord reports a ModalInteractionEvent.
      Overrides:
      onModalInteraction in class net.dv8tion.jda.api.hooks.ListenerAdapter
      Parameters:
      event - The ModalInteractionEvent that was fired.