fix stuff ig
This commit is contained in:
parent
0d38dbec49
commit
39f67c03e0
2 changed files with 9 additions and 7 deletions
|
@ -60,19 +60,19 @@ public class CommandHandlerPlugin {
|
||||||
final String[] fullArgs = Arrays.copyOfRange(splitInput, 1, splitInput.length);
|
final String[] fullArgs = Arrays.copyOfRange(splitInput, 1, splitInput.length);
|
||||||
final int longestUsageIndex = getLongestUsageIndex(command.usage());
|
final int longestUsageIndex = getLongestUsageIndex(command.usage());
|
||||||
final String usage = command.usage().get(longestUsageIndex);
|
final String usage = command.usage().get(longestUsageIndex);
|
||||||
final int minimumArgs = getMinimumArgs(usage);
|
final int minimumArgs = getMinimumArgs(usage, discord, command.trustLevel());
|
||||||
final int maximumArgs = getMaximumArgs(usage);
|
final int maximumArgs = getMaximumArgs(usage, discord, command.trustLevel());
|
||||||
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);
|
||||||
|
|
||||||
String userHash = "";
|
String userHash = "";
|
||||||
if (trustLevel > 0 && splitInput.length >= 2) userHash = splitInput[1];
|
if (trustLevel > 0 && splitInput.length >= 2) userHash = splitInput[1];
|
||||||
|
|
||||||
final String[] args = Arrays.copyOfRange(splitInput, (trustLevel > 0) ? 2 : 1, splitInput.length);
|
final String[] args = Arrays.copyOfRange(splitInput, (trustLevel > 0 && !discord) ? 2 : 1, splitInput.length);
|
||||||
|
|
||||||
// fix shit random messy code
|
// 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();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -134,7 +134,7 @@ public class CommandHandlerPlugin {
|
||||||
return longestIndex;
|
return longestIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getMinimumArgs(String usage) {
|
private static int getMinimumArgs(String usage, boolean discord, int trustLevel) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < usage.length(); i++) {
|
for (int i = 0; i < usage.length(); i++) {
|
||||||
if (usage.charAt(i) == '<') {
|
if (usage.charAt(i) == '<') {
|
||||||
|
@ -142,16 +142,18 @@ public class CommandHandlerPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (usage.contains("<hash>")) count--; // bad fix?
|
if (usage.contains("<hash>")) count--; // bad fix?
|
||||||
|
if ((discord && trustLevel > 0)) count--;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getMaximumArgs(String usage) {
|
private static int getMaximumArgs(String usage, boolean discord, int trustLevel) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < usage.length(); i++) {
|
for (int i = 0; i < usage.length(); i++) {
|
||||||
if (usage.charAt(i) == '<' || usage.charAt(i) == '[') {
|
if (usage.charAt(i) == '<' || usage.charAt(i) == '[') {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (discord && trustLevel > 0) count++;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,6 @@ package me.chayapak1.chomens_bot.util;
|
||||||
|
|
||||||
public class EscapeCodeBlock {
|
public class EscapeCodeBlock {
|
||||||
public static String escape (String message) {
|
public static String escape (String message) {
|
||||||
return message.replace("`", "\\`");
|
return message.replace("`", "\u200b`");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue