Class DIH4JDA

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

public class DIH4JDA extends net.dv8tion.jda.api.hooks.ListenerAdapter

Getting Started

Creating a new DIH4JDA instance is fairly easy:

 DIH4JDA dih4jda = DIH4JDABuilder
         .setJDA(jda) // Your JDA instance
         .build();
 
Now, you get to decide how you want your commands to be registered:

Manual Command Registration

To manually register commands, use the following methods, AFTER you've .build(); your DIH4JDA instance, like that:

 DIH4JDA dih4jda = DIH4JDABuilder
         .setJDA(jda) // Your JDA instance
         .build();
 dih4jda.addSlashCommands(new PingCommand(), new HelloWorldCommand());
 dih4jda.addContextMenus(new PingUserContext(), new HelloWorldMessageContext());
 

Automatic Command Registration

Alternatively, you can specify packages on the DIH4JDABuilder instance which will be scanned for all classes that extend one of the following classes:

 DIH4JDA dih4jda = DIH4JDABuilder
         .setJDA(jda) // Your JDA instance
         .setCommandPackages("xyz.dynxsty.bot.commands") // OPTIONAL: The package(s) that contains all your commands
         .build();
 
Upon calling .build();, the bot will register all commands that are in the specified package(s).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new DIH4JDA instance using the specified DIH4JDAConfig.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Binds all ButtonHandlers to their id using IdMapping
    void
    Manually registers ContextCommands.
    final void
    Binds all EntitySelectMenuHandlers to their id,
    void
    Allows to register event listener classes.
    final void
    Binds all ModalHandlers to their id.
    void
    Manually registers SlashCommands.
    final void
    Binds all StringSelectMenuHandlers to their id.
    net.dv8tion.jda.api.JDA
    Gets the JDA instance DIH4JDA uses.
    void
    onReady(net.dv8tion.jda.api.events.session.ReadyEvent event)
    Ran once the JDA instance fires the ReadyEvent.
    void
    Registers all Interactions and replaces the old ones.
    static void
    Sets the default RegistrationType for all Application Commands.

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

    onApplicationCommandUpdatePrivileges, onApplicationUpdatePrivileges, onAutoModExecution, onAutoModRuleCreate, onAutoModRuleDelete, onAutoModRuleUpdate, onButtonInteraction, onChannelCreate, onChannelDelete, onChannelUpdateAppliedTags, onChannelUpdateArchived, onChannelUpdateArchiveTimestamp, onChannelUpdateAutoArchiveDuration, onChannelUpdateBitrate, onChannelUpdateDefaultLayout, onChannelUpdateDefaultReaction, onChannelUpdateDefaultSortOrder, onChannelUpdateDefaultThreadSlowmode, onChannelUpdateFlags, onChannelUpdateInvitable, onChannelUpdateLocked, onChannelUpdateName, onChannelUpdateNSFW, onChannelUpdateParent, onChannelUpdatePosition, onChannelUpdateRegion, onChannelUpdateSlowmode, onChannelUpdateTopic, onChannelUpdateType, onChannelUpdateUserLimit, onChannelUpdateVoiceStatus, onCommandAutoCompleteInteraction, onEmojiAdded, onEmojiRemoved, onEmojiUpdateName, onEmojiUpdateRoles, onEntitlementCreate, onEntitlementDelete, onEntitlementUpdate, onEntitySelectInteraction, 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, onMessageContextInteraction, onMessageDelete, onMessagePollVoteAdd, onMessagePollVoteRemove, onMessageReactionAdd, onMessageReactionRemove, onMessageReactionRemoveAll, onMessageReactionRemoveEmoji, onMessageReceived, onMessageUpdate, onModalInteraction, onPermissionOverrideCreate, onPermissionOverrideDelete, onPermissionOverrideUpdate, onRawGateway, 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, onSlashCommandInteraction, onStageInstanceCreate, onStageInstanceDelete, onStageInstanceUpdatePrivacyLevel, onStageInstanceUpdateTopic, onStatusChange, onStringSelectInteraction, onThreadHidden, onThreadMemberJoin, onThreadMemberLeave, onThreadRevealed, onUnavailableGuildJoined, onUnavailableGuildLeave, onUserActivityEnd, onUserActivityStart, onUserContextInteraction, 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