Make the Discord command parsing more forgiving

This commit is contained in:
Allink 2023-07-25 04:13:40 +01:00
parent b2c636f919
commit ec19b6d398
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View File

@ -58,7 +58,7 @@ public class DiscordToMinecraftListener extends ListenerAdapter
final Message msg = event.getMessage();
final String content = msg.getContentStripped();
if (content.startsWith(ConfigEntry.DISCORD_PREFIX.getString()) && Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel))
if (content.toLowerCase().startsWith(ConfigEntry.DISCORD_PREFIX.getString().toLowerCase()) && Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel))
{
return;
}

View File

@ -48,20 +48,20 @@ public class DiscordCommandManager
public boolean parse(String content, Member member, TextChannel channel)
{
List<String> args = new ArrayList<>(Arrays.asList(content.split(" ")));
final String actualContent = content.substring(PREFIX.length()).trim();
List<String> args = new ArrayList<>(Arrays.asList(actualContent.split(" ")));
if (args.isEmpty())
{
return false;
}
final String[] aliasParts = args.remove(0).split(PREFIX);
if (aliasParts.length < 2)
final String alias = args.get(0);
if (alias.isEmpty())
{
return false;
}
final String alias = aliasParts[1];
for (DiscordCommand command : commands)
{
if (command.getCommandName().equalsIgnoreCase(alias) || command.getAliases().contains(alias.toLowerCase()))