Package dev.sympho.bot_utils.event
Interface EventContext
- All Superinterfaces:
AccessContext,AccessValidator
- All Known Subinterfaces:
ApplicationCommandEventContext,ButtonEventContext,ChannelEventContext,ComponentEventContext,DeferrableInteractionEventContext,InteractionEventContext,MessageBasedContext,MessageCreateEventContext,MessageEventContext,MessageIncludedContext,ModalEventContext,RepliableContext,SlashCommandEventContext
- All Known Implementing Classes:
AbstractChannelEventContext,AbstractEventContext,AbstractRepliableContext
The context of an user-triggered event received from Discord.
- Since:
- 1.0
- Version:
- 1.0
- Implementation Requirements:
- A context must be effectively constant; that is, an implementation of this interface
must always return the same value on methods that return a direct value (such as
AccessContext.user()orAccessContext.guildId()). Methods that fetch remote resources (i.e. that return a Mono) may return different objects over time (as the remote object is modified), but must always reference the same entity.
-
Method Summary
Modifier and TypeMethodDescriptionbelongs(Snowflake user, GuildGroup group) Determines whether the given user belongs to the given group in the context of this event.belongs(User user, GuildGroup group) Determines whether the given user belongs to the given group in the context of this event.default GatewayDiscordClientclient()Retrieves the backing client.event()Retrieves the triggering event.hasAccess(GuildGroup group) Determines whether the invoking user in the current execution context has access equivalent to the given group.validate(GuildGroup group) Determines whether the invoking user in the current execution context has access equivalent to the given group.The access validator used in this context.
-
Method Details
-
event
Event event()Retrieves the triggering event.- Returns:
- The event.
-
client
Description copied from interface:AccessContextRetrieves the backing client.- Specified by:
clientin interfaceAccessContext- Returns:
- The client.
-
validator
The access validator used in this context.- Returns:
- The validator.
-
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.
- See Also:
- API Note:
- This is a convenience shortcut for using the
context validator. It is equivalent tovalidator().hasAccess(group).
-
validate
Description copied from interface:AccessValidatorDetermines whether the invoking user in the current execution context has access equivalent to the given group.- Specified by:
validatein interfaceAccessValidator- Parameters:
group- The group required for access.- Returns:
- A Mono that completes empty if the caller has access equivalent to the given
group under the current execution context, or otherwise issues an error of type
AccessException. - See Also:
- API Note:
- This is a convenience shortcut for using the
context validator. It is equivalent tovalidator().validate(group).
-
belongs
Determines whether the given user belongs to the given group in the context of this event.- Parameters:
user- The user to check for.group- The group to check for.- Returns:
- A Mono that emits
trueif the given user belongs to the given group under this event context, orfalseotherwise. - API Note:
- This is a convenience method equivalent to
group.belongs(user, this).
-
belongs
Determines whether the given user belongs to the given group in the context of this event.- Parameters:
user- The ID of the user to check for.group- The group to check for.- Returns:
- A Mono that emits
trueif the given user belongs to the given group under this event context, orfalseotherwise. - API Note:
- This is a convenience method equivalent to fetching the user then invoking
group.belongs(user, this).
-