Package xyz.dynxsty.dih4jda
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
DIH4JDA
Creating a new DIH4JDA instance:
DIH4JDA dih4JDA = DIH4JDABuilder
.setJDA(jda) // Your JDA instance
.setCommandsPackages("com.dynxsty.superawesomebot.commands") // The main package where all your commands are in.
.build();
Upon calling .build();, the bot will automatically register all Commands that are in the given commandsPackage.
(if not disabled)-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic RegistrationTypeThe defaultRegistrationTypewhich is used for queuing new commands. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddButtonHandlers(Map<List<String>, ButtonHandler> handlers) Binds allButtonHandlers to their id.voidaddContextCommands(ContextCommand... commands) Manually registersContextCommands.voidaddEntitySelectMenuHandlers(Map<List<String>, EntitySelectMenuHandler> handlers) Binds allEntitySelectMenuHandlers to their id,voidaddEventListener(Object... classes) Allows to add Listener classes (that implementsDIH4JDAEventListener).voidaddModalHandlers(Map<List<String>, ModalHandler> handlers) Binds allModalHandlers to their id.voidaddSlashCommands(SlashCommand... commands) Manually registersSlashCommands.voidaddStringSelectMenuHandlers(Map<List<String>, StringSelectMenuHandler> handlers) Binds allStringSelectMenuHandlers to their id.Gets allButtonHandlers.Gets all registeredEntitySelectMenuHandlers.net.dv8tion.jda.api.JDAgetJDA()Convenience method which replaces}invalid @link
{@link DIH4JDA#getConfig()#getJDA()Gets allModalHandlers.Gets all registeredStringSelectMenuHandlers.voidonReady(net.dv8tion.jda.api.events.session.ReadyEvent event) Ran once theJDAinstance fires theReadyEvent.voidRegisters all Interactions and replaces the old ones.Methods inherited from class net.dv8tion.jda.api.hooks.ListenerAdapter
onApplicationCommandUpdatePrivileges, onApplicationUpdatePrivileges, onButtonInteraction, onChannelCreate, onChannelDelete, onChannelUpdateAppliedTags, onChannelUpdateArchived, onChannelUpdateArchiveTimestamp, onChannelUpdateAutoArchiveDuration, onChannelUpdateBitrate, onChannelUpdateDefaultReaction, onChannelUpdateDefaultThreadSlowmode, onChannelUpdateFlags, onChannelUpdateInvitable, onChannelUpdateLocked, onChannelUpdateName, onChannelUpdateNSFW, onChannelUpdateParent, onChannelUpdatePosition, onChannelUpdateRegion, onChannelUpdateSlowmode, onChannelUpdateTopic, onChannelUpdateType, onChannelUpdateUserLimit, onCommandAutoCompleteInteraction, onEmojiAdded, onEmojiRemoved, onEmojiUpdateName, onEmojiUpdateRoles, onEntitySelectInteraction, onEvent, onException, onForumTagAdd, onForumTagRemove, onForumTagUpdateEmoji, onForumTagUpdateModerated, onForumTagUpdateName, onGatewayPing, onGenericAutoCompleteInteraction, onGenericChannel, onGenericChannelUpdate, onGenericCommandInteraction, onGenericComponentInteractionCreate, onGenericContextInteraction, onGenericEmoji, onGenericEmojiUpdate, onGenericEvent, onGenericForumTag, onGenericForumTagUpdate, onGenericGuild, onGenericGuildInvite, onGenericGuildMember, onGenericGuildMemberUpdate, onGenericGuildSticker, onGenericGuildStickerUpdate, onGenericGuildUpdate, onGenericGuildVoice, onGenericInteractionCreate, onGenericMessage, onGenericMessageReaction, onGenericPermissionOverride, onGenericPrivilegeUpdate, onGenericRole, onGenericRoleUpdate, onGenericScheduledEventUpdate, onGenericSelectMenuInteraction, onGenericSelfUpdate, onGenericSessionEvent, onGenericStageInstance, onGenericStageInstanceUpdate, onGenericThread, onGenericThreadMember, onGenericUpdate, onGenericUser, onGenericUserPresence, onGuildAvailable, onGuildBan, onGuildInviteCreate, onGuildInviteDelete, onGuildJoin, onGuildLeave, onGuildMemberJoin, onGuildMemberRemove, onGuildMemberRoleAdd, onGuildMemberRoleRemove, onGuildMemberUpdate, onGuildMemberUpdateAvatar, onGuildMemberUpdateBoostTime, 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, onMessageEmbed, onMessageReactionAdd, onMessageReactionRemove, onMessageReactionRemoveAll, onMessageReactionRemoveEmoji, onMessageReceived, onMessageUpdate, onModalInteraction, onPermissionOverrideCreate, onPermissionOverrideDelete, onPermissionOverrideUpdate, onRawGateway, onRoleCreate, onRoleDelete, onRoleUpdateColor, onRoleUpdateHoisted, onRoleUpdateIcon, onRoleUpdateMentionable, onRoleUpdateName, onRoleUpdatePermissions, onRoleUpdatePosition, onScheduledEventCreate, onScheduledEventDelete, onScheduledEventUpdateDescription, onScheduledEventUpdateEndTime, onScheduledEventUpdateLocation, onScheduledEventUpdateName, onScheduledEventUpdateStartTime, onScheduledEventUpdateStatus, onScheduledEventUserAdd, onScheduledEventUserRemove, onSelfUpdateAvatar, 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, onUserUpdateName, onUserUpdateOnlineStatus
-
Field Details
-
defaultCommandType
The defaultRegistrationTypewhich is used for queuing new commands. This can be overridden usingBaseCommandRequirements.setRegistrationType(RegistrationType)
-
-
Method Details
-
onReady
public void onReady(@Nonnull net.dv8tion.jda.api.events.session.ReadyEvent event) Ran once theJDAinstance fires theReadyEvent.- Overrides:
onReadyin classnet.dv8tion.jda.api.hooks.ListenerAdapter- Parameters:
event- TheReadyEventthat was fired.
-
registerInteractions
Registers all Interactions and replaces the old ones. Please note that global commands may need up to an hour before they're fully registered.- Throws:
ReflectiveOperationException
-
getConfig
- Returns:
- The instance's configuration.
-
addEventListener
Allows to add Listener classes (that implementsDIH4JDAEventListener).- Since:
- v1.5
-
getJDA
@Nonnull public net.dv8tion.jda.api.JDA getJDA()Convenience method which replaces}invalid @link
{@link DIH4JDA#getConfig()#getJDA()- Returns:
- The
JDAinstance.
-
addSlashCommands
Manually registersSlashCommands.- Parameters:
commands- An array of commands to register.
-
addContextCommands
Manually registersContextCommands.- Parameters:
commands- An array of commands to register.
-
addButtonHandlers
Binds allButtonHandlers to their id.
dih4jda.addButtonHandlers(Map.of( List.of("apple"), new AppleButtonHandler(), List.of("banana"), new BananaButtonHandler() ));
This is best used in combination withComponentIdBuilder.build(String, Object...).- Parameters:
handlers- AllButtonHandler, as a immutableMap.
-
getButtonHandlers
Gets allButtonHandlers.- Returns:
- An immutable
Mapwhich stores the id as the Key and theButtonHandleras the Value.
-
addStringSelectMenuHandlers
Binds allStringSelectMenuHandlers to their id.
dih4jda.addStringSelectMenuHandlers(Map.of( List.of("apple"), new AppleSelectMenuHandler(), List.of("banana"), new BananaSelectMenuHandler() ));
This is best used in combination withComponentIdBuilder.build(String, Object...).- Parameters:
handlers- AllStringSelectMenuHandler, as a immutableMap.- See Also:
-
addEntitySelectMenuHandlers
Binds allEntitySelectMenuHandlers to their id,
dih4jda.addEntitySelectMenuHandlers(Map.of( List.of("apple"), new AppleSelectMenuHandler(), List.of("banana"), new BananaSelectMenuHandler() ));
* This is best used in combination withComponentIdBuilder.build(String, Object...).- Parameters:
handlers- AllEntitySelectMenuHandler, as a immutableMap.- See Also:
-
getStringSelectMenuHandlers
Gets all registeredStringSelectMenuHandlers.- Returns:
- An immutable
Mapwhich stores the id as the Key and theStringSelectMenuHandleras the value. - See Also:
-
getEntitySelectMenuHandlers
Gets all registeredEntitySelectMenuHandlers.- Returns:
- An immutable
Mapwhich stores the id as the Key and theEntitySelectMenuHandleras the values. - See Also:
-
addModalHandlers
Binds allModalHandlers to their id.
dih4jda.addModalHandlers(Map.of( List.of("apple"), new AppleModalHandler(), List.of("banana"), new BananaModalHandler() ));
This is best used in combination withComponentIdBuilder.build(String, Object...).- Parameters:
handlers- AllModalHandler, as a immutableMap.
-
getModalHandlers
Gets allModalHandlers.- Returns:
- An immutable
Mapwhich stores the id as the Key and theModalHandleras the Value.
-