mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Fix invalid Discord command handling
This commit is contained in:
parent
8876076a9d
commit
b2c636f919
@ -58,9 +58,8 @@ public class DiscordToMinecraftListener extends ListenerAdapter
|
|||||||
final Message msg = event.getMessage();
|
final Message msg = event.getMessage();
|
||||||
final String content = msg.getContentStripped();
|
final String content = msg.getContentStripped();
|
||||||
|
|
||||||
if (content.startsWith(ConfigEntry.DISCORD_PREFIX.getString()))
|
if (content.startsWith(ConfigEntry.DISCORD_PREFIX.getString()) && Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel))
|
||||||
{
|
{
|
||||||
Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,21 @@ public class DiscordCommandManager
|
|||||||
FLog.info("Loaded " + commands.size() + " Discord commands.");
|
FLog.info("Loaded " + commands.size() + " Discord commands.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parse(String content, Member member, TextChannel channel)
|
public boolean parse(String content, Member member, TextChannel channel)
|
||||||
{
|
{
|
||||||
List<String> args = new ArrayList<>(Arrays.asList(content.split(" ")));
|
List<String> args = new ArrayList<>(Arrays.asList(content.split(" ")));
|
||||||
|
if (args.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final String alias = args.remove(0).split(PREFIX)[1]; // The joys of command parsing
|
final String[] aliasParts = args.remove(0).split(PREFIX);
|
||||||
|
if (aliasParts.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String alias = aliasParts[1];
|
||||||
|
|
||||||
for (DiscordCommand command : commands)
|
for (DiscordCommand command : commands)
|
||||||
{
|
{
|
||||||
@ -63,6 +73,7 @@ public class DiscordCommandManager
|
|||||||
final CompletableFuture<Message> futureMessage = channel.sendMessage(message).submit(true);
|
final CompletableFuture<Message> futureMessage = channel.sendMessage(message).submit(true);
|
||||||
|
|
||||||
this.discord.sentMessages.add(futureMessage);
|
this.discord.sentMessages.add(futureMessage);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -77,8 +88,11 @@ public class DiscordCommandManager
|
|||||||
final CompletableFuture<Message> futureMessage = channel.sendMessage(message).submit(true);
|
final CompletableFuture<Message> futureMessage = channel.sendMessage(message).submit(true);
|
||||||
|
|
||||||
this.discord.sentMessages.add(futureMessage);
|
this.discord.sentMessages.add(futureMessage);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user