actually fix a major exploit

This commit is contained in:
Chayapak 2023-04-01 12:45:57 +07:00
parent c9b02159bc
commit fed86cdbb2
5 changed files with 11 additions and 9 deletions

View file

@ -21,10 +21,10 @@ public class CloopCommand implements Command {
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
usages.add("add <interval> <{command}>"); usages.add("<hash> add <interval> <{command}>");
usages.add("remove <index>"); usages.add("<hash> remove <index>");
usages.add("clear"); usages.add("<hash> clear");
usages.add("list"); usages.add("<hash> list");
return usages; return usages;
} }

View file

@ -17,7 +17,7 @@ public class EndCommand implements Command {
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
usages.add(""); usages.add("<hash>");
return usages; return usages;
} }

View file

@ -20,7 +20,7 @@ public class ServerEvalCommand implements Command {
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
usages.add("<{code}>"); usages.add("<ownerHash> <{code}>");
return usages; return usages;
} }

View file

@ -19,7 +19,7 @@ public class SudoAllCommand implements Command {
public List<String> usage() { public List<String> usage() {
final List<String> usages = new ArrayList<>(); final List<String> usages = new ArrayList<>();
usages.add("<{c:message|command}>"); usages.add("<hash> <{c:message|command}>");
return usages; return usages;
} }

View file

@ -53,6 +53,7 @@ public class CommandHandlerPlugin {
commands.add(command); commands.add(command);
} }
// literally the same quality as the js chomens bot
public Component executeCommand (String input, CommandContext context, boolean inGame, boolean discord, String hash, String ownerHash, MessageReceivedEvent event) { public Component executeCommand (String input, CommandContext context, boolean inGame, boolean discord, String hash, String ownerHash, MessageReceivedEvent event) {
final String[] splitInput = input.split("\\s+"); final String[] splitInput = input.split("\\s+");
@ -72,12 +73,13 @@ public class CommandHandlerPlugin {
if (fullArgs.length < minimumArgs) return Component.text("Excepted minimum of " + minimumArgs + " argument(s), got " + fullArgs.length).color(NamedTextColor.RED); if (fullArgs.length < minimumArgs) return Component.text("Excepted minimum of " + minimumArgs + " argument(s), got " + fullArgs.length).color(NamedTextColor.RED);
if (fullArgs.length > maximumArgs && !usage.contains("{")) return Component.text("Too much arguments, expected " + maximumArgs + " max").color(NamedTextColor.RED); if (fullArgs.length > maximumArgs && !usage.contains("{")) return Component.text("Too much arguments, expected " + maximumArgs + " max").color(NamedTextColor.RED);
if (trustLevel > 0 && splitInput.length < 2) return Component.text("Please provide a hash").color(NamedTextColor.RED);
String userHash = ""; String userHash = "";
if (trustLevel > 0 && splitInput.length >= 2) userHash = splitInput[1]; if (trustLevel > 0) userHash = splitInput[1];
final String[] args = Arrays.copyOfRange(splitInput, (trustLevel > 0 && inGame) ? 2 : 1, splitInput.length); final String[] args = Arrays.copyOfRange(splitInput, (trustLevel > 0 && inGame) ? 2 : 1, splitInput.length);
// fix shit random messy code
if (command.trustLevel() > 0) { if (command.trustLevel() > 0) {
if (discord) { if (discord) {
final List<Role> roles = event.getMember().getRoles(); final List<Role> roles = event.getMember().getRoles();