Class PermissionsMiddleware
java.lang.Object
io.github.kaktushose.jdac.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 TypeMethodDescriptionvoidaccept(InvocationContext<?> context) Checks if theUserand respectively theMemberhas the permission to execute the command.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Middleware
runFor
-
Constructor Details
-
PermissionsMiddleware
public PermissionsMiddleware(PermissionsProvider permissionsProvider, ErrorMessageFactory errorMessageFactory)
-
-
Method Details
-
accept
Checks if theUserand respectively theMemberhas the permission to execute the command.- Specified by:
acceptin interfaceConsumer<InvocationContext<?>>- Specified by:
acceptin interfaceMiddleware- Parameters:
context- theInvocationContextto filter
-