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)-
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddButtonMappings(IdMapping<ButtonHandler>... mappings) voidaddContextCommands(ContextCommand<?>... commands) Manually registersContextCommands.final voidaddEntitySelectMenuMappings(IdMapping<EntitySelectMenuHandler>... mappings) Binds allEntitySelectMenuHandlers to their id,voidaddEventListener(Object... classes) Allows to add Listener classes (that implementsDIH4JDAEventListener).final voidaddModalMappings(IdMapping<ModalHandler>... mappings) Binds allModalHandlers to their id.voidaddSlashCommands(SlashCommand... commands) Manually registersSlashCommands.final voidaddStringSelectMenuMappings(IdMapping<StringSelectMenuHandler>... mappings) Binds allStringSelectMenuHandlers to their id.final IdMapping<ButtonHandler>[]Gets allButtonHandlers.static RegistrationTypefinal IdMapping<EntitySelectMenuHandler>[]Gets all registeredEntitySelectMenuHandlers.net.dv8tion.jda.api.JDAgetJDA()Convenience method which replaces}invalid @link
{@link DIH4JDA#getConfig()#getJDA()final IdMapping<ModalHandler>[]Gets allModalHandlers.final IdMapping<StringSelectMenuHandler>[]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.static voidSets the defaultRegistrationTypefor all Commands.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
-
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.
-
setDefaultRegistrationType
Sets the defaultRegistrationTypefor all Commands. This is set toRegistrationType.GLOBALif not set otherwise.- Parameters:
type- TheRegistrationType.
-
getDefaultRegistrationType
-
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
-
getEventListeners
- Returns:
- A set of all Listener classes.
- See Also:
-
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.
-
addButtonMappings
Binds allButtonHandlers to their id usingIdMapping
dih4jda.addButtonMappings( IdMapping.of(new PingCommand(), "ping", "hello-world"), IdMapping.of(new DummyCommand(), "dummy", "test") );
This is best used in combination withComponentIdBuilder.build(String, Object...).- Parameters:
mappings- AllButtonHandler, as an array ofIdMapping.
-
getButtonMappings
Gets allButtonHandlers.- Returns:
- An
IdMappingarray which contains the never-null ids and handlers.
-
addStringSelectMenuMappings
@SafeVarargs public final void addStringSelectMenuMappings(IdMapping<StringSelectMenuHandler>... mappings) Binds allStringSelectMenuHandlers to their id.
dih4jda.addStringSelectMenuMappings( IdMapping.of(new PingCommand(), "ping", "hello-world"), IdMapping.of(new DummyCommand(), "dummy", "test") );
This is best used in combination withComponentIdBuilder.build(String, Object...).- Parameters:
mappings- AllStringSelectMenuHandler, as an array ofIdMapping.- See Also:
-
getStringSelectMenuMappings
Gets all registeredStringSelectMenuHandlers.- Returns:
- An
IdMappingarray which contains the never-null ids and handlers. - See Also:
-
addEntitySelectMenuMappings
@SafeVarargs public final void addEntitySelectMenuMappings(IdMapping<EntitySelectMenuHandler>... mappings) Binds allEntitySelectMenuHandlers to their id,
dih4jda.addEntitySelectMenuMappings( IdMapping.of(new PingCommand(), "ping", "hello-world"), IdMapping.of(new DummyCommand(), "dummy", "test") );
This is best used in combination withComponentIdBuilder.build(String, Object...).- Parameters:
mappings- AllEntitySelectMenuHandler, as an array ofIdMapping.- See Also:
-
getEntitySelectMenuMappings
Gets all registeredEntitySelectMenuHandlers.- Returns:
- An
IdMappingarray which contains the never-null ids and handlers. - See Also:
-
addModalMappings
Binds allModalHandlers to their id.
dih4jda.addModalMappings( IdMapping.of(new PingCommand(), "ping", "hello-world"), IdMapping.of(new DummyCommand(), "dummy", "test") );
This is best used in combination withComponentIdBuilder.build(String, Object...).- Parameters:
mappings- AllModalHandler, as an array ofIdMapping.
-
getModalMappings
Gets allModalHandlers.- Returns:
- An
IdMappingarray which contains the never-null ids and handlers.
-