mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Make the Discord command parsing more forgiving
This commit is contained in:
parent
b2c636f919
commit
ec19b6d398
@ -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;
|
||||
}
|
||||
|
@ -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()))
|
||||
|
Loading…
Reference in New Issue
Block a user