File tree Expand file tree Collapse file tree
src/main/java/dev/zenith/web Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,4 +8,5 @@ public class WebAPIConfig {
88 public String authToken = UUID .randomUUID ().toString ();
99 public boolean rateLimiter = true ;
1010 public int rateLimitRequestsPerMinute = 30 ;
11+ public boolean commandsAccountOwnerPerms = false ;
1112}
Original file line number Diff line number Diff line change 55import com .zenith .command .api .CommandSource ;
66import com .zenith .discord .Embed ;
77
8+ import static dev .zenith .web .WebApiPlugin .PLUGIN_CONFIG ;
9+
810public class WebAPICommandSource implements CommandSource {
911 public static final WebAPICommandSource INSTANCE = new WebAPICommandSource ();
1012
@@ -15,9 +17,13 @@ public String name() {
1517
1618 @ Override
1719 public boolean validateAccountOwner (final CommandContext ctx ) {
18- ctx .getEmbed ()
19- .description ("Web API is not authorized to execute this command!" );
20- return false ;
20+ if (PLUGIN_CONFIG .commandsAccountOwnerPerms ) {
21+ return true ;
22+ } else {
23+ ctx .getEmbed ()
24+ .description ("Web API is not authorized to execute this command!" );
25+ return false ;
26+ }
2127 }
2228
2329 @ Override
Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ public CommandUsage commandUsage() {
2828 .usageLines (
2929 "on/off" ,
3030 "port <port>" ,
31- "auth <token>"
31+ "auth <token>" ,
32+ "commandsAccountOwnerPerms on/off"
3233 )
3334 .build ();
3435 }
@@ -58,6 +59,11 @@ public LiteralArgumentBuilder<CommandContext> register() {
5859 PLUGIN_CONFIG .authToken = getString (c , "token" );
5960 c .getSource ().getEmbed ()
6061 .title ("Auth Token Set" );
62+ })))
63+ .then (literal ("commandsAccountOwnerPerms" ).then (argument ("toggle" , toggle ()).executes (c -> {
64+ PLUGIN_CONFIG .commandsAccountOwnerPerms = getToggle (c , "toggle" );
65+ c .getSource ().getEmbed ()
66+ .title ("Commands Account Owner Perms " + toggleStrCaps (PLUGIN_CONFIG .commandsAccountOwnerPerms ));
6167 })));
6268 }
6369
@@ -67,6 +73,7 @@ public void defaultEmbed(Embed embed) {
6773 .addField ("Web API" , SERVER .isRunning () ? "Running" : "Stopped" )
6874 .addField ("Port" , PLUGIN_CONFIG .port )
6975 .addField ("Auth Token" , PLUGIN_CONFIG .authToken )
76+ .addField ("Commands Account Owner Perms" , PLUGIN_CONFIG .commandsAccountOwnerPerms )
7077 .primaryColor ();
7178 }
7279}
You can’t perform that action at this time.
0 commit comments