Class EventContext
java.lang.Object
de.chojo.jdautil.wrapper.EventContext
-
Constructor Summary
ConstructorsConstructorDescriptionEventContext(@Nullable IReplyCallback event, ConversationService conversationService, ILocalizer localizer, MenuService menus, PageService pages, ModalService modalService, InteractionHub<?, ?, ?> interactionHub, List<SKU> entitlements) -
Method Summary
Modifier and TypeMethodDescriptionInteractionHub<?, ?, ?> Deprecated, for removal: This API element is subject to removal in a future version.Registers a new conversation.Returns the list of entitlements for the current guild and user.event()guildLocale(String message, Replacement... replacements) Localizes the key with the defined language of the guild or by the locale provided by theLocalizer.Builder.withLanguageProvider(Function)when the language is the default value.Returns a guild localizer.InteractionHub<?, ?, ?> Returns the interaction hub, which dispatched the interactionlocalize(String message, Replacement... replacements) Localizes a message with the guild locale if the event happened on a guild.Deprecated, for removal: This API element is subject to removal in a future version.Removed in favor orguildLocalizer()menus()pages()voidregisterMenu(MenuAction action) Registers a new menu action.voidregisterModal(ModalHandler modalHandler) Registers a new modal Requires that aModalServiceis registered viaInteractionHubBuilder.withModalService(Consumer)orInteractionHubBuilder.withDefaultModalService()voidregisterPage(IPageBag page) Registers a new page.voidregisterPage(IPageBag page, boolean ephemeral) Registers a new page.voidstartDialog(Conversation conversation) Registers a new conversation.userLocale(String message, Replacement... replacements) Localizes the key with the defined language of the user.Returns a user localizer, which uses theInteraction.getUserLocale()
-
Constructor Details
-
Method Details
-
conversationService
Registers a new conversation.Requires that a
ConversationServiceis registered viaInteractionHubBuilder.withConversationSystem() -
startDialog
Registers a new conversation.Requires that a
ConversationServiceis registered viaInteractionHubBuilder.withConversationSystem()- Parameters:
conversation- conversation to start
-
localize
Localizes a message with the guild locale if the event happened on a guild. Will use user locale if it happened in a private message.- Parameters:
message- messagereplacements- replacements- Returns:
- localized message
-
guildLocale
Localizes the key with the defined language of the guild or by the locale provided by theLocalizer.Builder.withLanguageProvider(Function)when the language is the default value.- Parameters:
message- messagereplacements- replacements- Returns:
- localized message
-
userLocale
Localizes the key with the defined language of the user.- Parameters:
message- messagereplacements- replacements- Returns:
- localized message
-
registerPage
Registers a new page.Requires that a
PageServiceis registered viaInteractionHubBuilder.withPagination(Consumer)orInteractionHubBuilder.withDefaultPagination()- Parameters:
page- page to register
-
registerPage
Registers a new page.Requires that a
PageServiceis registered viaInteractionHubBuilder.withPagination(Consumer)orInteractionHubBuilder.withDefaultPagination()- Parameters:
page- page to registerephemeral- true so send the reply ephemeral
-
registerModal
Registers a new modal Requires that aModalServiceis registered viaInteractionHubBuilder.withModalService(Consumer)orInteractionHubBuilder.withDefaultModalService()- Parameters:
modalHandler- modal handler
-
guildLocalizer
Returns a guild localizer. It uses the language from the language provider, else the guild's Discord locale (Guild.getLocale()), else the default language.- Returns:
- localizer with guild locale linked
-
localizer
Deprecated, for removal: This API element is subject to removal in a future version.Removed in favor orguildLocalizer()- Returns:
- guild localizer
-
userLocalizer
Returns a user localizer, which uses theInteraction.getUserLocale()- Returns:
- localizer with user locale linked
-
commandHub
Deprecated, for removal: This API element is subject to removal in a future version.deprecated in favor ofinteractionHub()Returns the command hub- Returns:
- command hub
-
interactionHub
Returns the interaction hub, which dispatched the interaction- Returns:
- interaction hub instance
-
entitlements
Returns the list of entitlements for the current guild and user. If this interaction is not from a guild, it will only contain entitlements of the user.- Returns:
- list of entitlements
-
event
-
pages
-
modalService
-
interactionHub()