-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix common interceptors not found issue
- Loading branch information
1 parent
ca6b488
commit b904373
Showing
3 changed files
with
29 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...w/mihou/nexus/features/command/interceptors/commons/core/NexusCommonInterceptorsCore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package pw.mihou.nexus.features.command.interceptors.commons.core; | ||
|
||
import pw.mihou.nexus.features.command.interceptors.commons.NexusCommonInterceptors; | ||
import pw.mihou.nexus.features.command.interceptors.facades.NexusCommandInterceptor; | ||
import pw.mihou.nexus.features.messages.facade.NexusMessage; | ||
import pw.mihou.nexus.features.ratelimiter.core.NexusRatelimiterCore; | ||
|
||
public class NexusCommonInterceptorsCore extends NexusCommonInterceptors { | ||
|
||
public static void addAll() { | ||
NexusCommandInterceptor.addMiddleware(NEXUS_AUTH_BOT_OWNER_MIDDLEWARE, event -> event.stopIf( | ||
!event.getUser().isBotOwner(), | ||
NexusMessage.fromEphemereal("**PERMISSION DENIED**\nYou need to be the bot owner to execute this command.") | ||
)); | ||
|
||
NexusCommandInterceptor.addMiddleware(NEXUS_AUTH_SERVER_OWNER_MIDDLEWARE, event -> event.stopIf( | ||
event.getServer().isPresent() && event.getServer().get().isOwner(event.getUser()), | ||
NexusMessage.fromEphemereal("**PERMISSION DENIED**\nYou need to be the server owner to execute this command.") | ||
)); | ||
|
||
NexusCommandInterceptor.addMiddleware(NEXUS_GATE_SERVER, event -> event.stopIf(event.getServer().isEmpty())); | ||
NexusCommandInterceptor.addMiddleware(NEXUS_GATE_DMS, event -> event.stopIf(event.getServer().isPresent())); | ||
NexusCommandInterceptor.addMiddleware(NEXUS_RATELIMITER, new NexusRatelimiterCore()); | ||
} | ||
|
||
} |