Class PermissionsMiddleware
java.lang.Object
com.github.kaktushose.jda.commands.dispatching.middleware.impl.PermissionsMiddleware
- All Implemented Interfaces:
Middleware
,Consumer<InvocationContext<?>>
A
Middleware
implementation that will check permissions.
The default implementation can only handle discord permissions. However, the PermissionsProvider
can be
used for own implementations.
This filter will first check against PermissionsProvider.hasPermission(User,InvocationContext)
with a
User
object. This can be used for global permissions. Afterward
PermissionsProvider.hasPermission(User,InvocationContext)
will be called. Since the Member
is
available this might be used for guild related permissions.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPermissionsMiddleware
(PermissionsProvider permissionsProvider, ErrorMessageFactory errorMessageFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(@NotNull InvocationContext<?> context) Checks if theUser
and respectively theMember
has the permission to execute the command.
-
Constructor Details
-
PermissionsMiddleware
public PermissionsMiddleware(PermissionsProvider permissionsProvider, ErrorMessageFactory errorMessageFactory)
-
-
Method Details
-
accept
Checks if theUser
and respectively theMember
has the permission to execute the command.- Specified by:
accept
in interfaceConsumer<InvocationContext<?>>
- Specified by:
accept
in interfaceMiddleware
- Parameters:
context
- theInvocationContext
to filter
-