Package dev.sympho.bot_utils.component
Class ComponentManager.ComponentContext<E extends @NonNull ComponentInteractionEvent>
java.lang.Object
dev.sympho.bot_utils.component.ComponentManager.ComponentContext<E>
- Type Parameters:
E- The event type.
- All Implemented Interfaces:
AccessContext,AccessValidator,ChannelAccessContext
- Direct Known Subclasses:
ButtonManager.ButtonContext,ModalManager.ModalContext
- Enclosing class:
- ComponentManager<E extends @NonNull ComponentInteractionEvent,
C extends @NonNull ComponentManager.ComponentContext<E>, HF extends @NonNull ComponentManager.HandlerFunction<C>, H extends @NonNull ComponentManager.Handler<H, HF>, HE extends @NonNull ComponentManager.HandlerEntry<H>>
public static class ComponentManager.ComponentContext<E extends @NonNull ComponentInteractionEvent>
extends Object
implements ChannelAccessContext, AccessValidator
The execution context of a component being interacted with.
- Since:
- 1.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedComponentContext(E event, AccessManager accessManager) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the channel.Retrieves the ID of the channel.Retrieves the backing client.getEvent()Retrieves the triggering event.getGuild()Retrieves the guild, if there is one.Retrieves the ID of the guild, if there is one.Retrieves the interaction associated with the event.Retrieves the user as a guild member.Retrieves the user as a guild member of the given guild.Retrieves the message that the component is attached to.Retrieves the ID of the message that the component is attached to.getUser()Retrieves the user.Determines whether the invoking user in the current execution context has access equivalent to the given group.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.sympho.bot_utils.access.AccessContext
asGuild, isPrivateMethods inherited from interface dev.sympho.bot_utils.access.AccessValidator
validateMethods inherited from interface dev.sympho.bot_utils.access.ChannelAccessContext
asUser
-
Constructor Details
-
ComponentContext
Creates a new instance.- Parameters:
event- The triggering event.accessManager- The access manager to use.
-
-
Method Details
-
getEvent
Retrieves the triggering event.- Returns:
- The event.
-
getClient
Description copied from interface:AccessContextRetrieves the backing client.- Specified by:
getClientin interfaceAccessContext- Returns:
- The client.
-
getGuild
Description copied from interface:AccessContextRetrieves the guild, if there is one.- Specified by:
getGuildin interfaceAccessContext- Returns:
- The invoking guild.
-
getGuildId
Description copied from interface:AccessContextRetrieves the ID of the guild, if there is one.- Specified by:
getGuildIdin interfaceAccessContext- Returns:
- The guild's ID, or
nullif a private channel.
-
getUser
Description copied from interface:AccessContextRetrieves the user.- Specified by:
getUserin interfaceAccessContext- Returns:
- The user.
-
getMember
Description copied from interface:AccessContextRetrieves the user as a guild member.- Specified by:
getMemberin interfaceAccessContext- Returns:
- The calling user as a guild member. May be empty if the context is a private channel.
-
getMember
Description copied from interface:AccessContextRetrieves the user as a guild member of the given guild.- Specified by:
getMemberin interfaceAccessContext- Parameters:
guildId- The ID of the target guild.- Returns:
- The user as a guild member of the given guild.
-
getChannel
Description copied from interface:ChannelAccessContextRetrieves the channel.- Specified by:
getChannelin interfaceChannelAccessContext- Returns:
- The channel.
-
getChannelId
Description copied from interface:ChannelAccessContextRetrieves the ID of the channel.- Specified by:
getChannelIdin interfaceChannelAccessContext- Returns:
- The channel's ID.
-
getMessage
Retrieves the message that the component is attached to.If the message is ephemeral, only
the IDwill be present.- Returns:
- The message, or
nullif the message is ephemeral.
-
getMessageId
Retrieves the ID of the message that the component is attached to.- Returns:
- The message ID.
-
getInteraction
Retrieves the interaction associated with the event.- Returns:
- The interaction.
-
hasAccess
Description copied from interface:AccessValidatorDetermines whether the invoking user in the current execution context has access equivalent to the given group.Note that while the most straightforward implementation of this interface is to simply check if the caller
belongsto the given group, implementations are allowed to add other conditions under which a user has equivalent permissions despite not belonging to the group (or conversely does not have permissions despite belonging to the group).- Specified by:
hasAccessin interfaceAccessValidator- Parameters:
group- The group required for access.- Returns:
- Whether the caller has access equivalent to the given group under the current execution context.
-