use of io.github.lxgaming.discordbot.entries.ICommand in project DiscordBot by LXGaming.
the class Command method execute.
public void execute(TextChannel textChannel, Member member, Message message) {
List<String> arguments;
if (message.getContent().startsWith(DiscordBot.getInstance().getConfig().getCommandPrefix())) {
arguments = getValidArguments(DiscordUtil.filter(message.getContent().substring(DiscordBot.getInstance().getConfig().getCommandPrefix().length())).split(" "));
} else {
arguments = getValidArguments(DiscordUtil.filter(message.getContent().substring(1)).split(" "));
}
if (arguments == null || arguments.size() < 1) {
return;
}
for (Iterator<ICommand> iterator = getRegisteredCommands().iterator(); iterator.hasNext(); ) {
ICommand command = iterator.next();
if (checkCommandName(arguments.get(0), command.getName()) || checkCommandAliases(arguments.get(0), command.getAliases())) {
LogHelper.debug("Processing Command '" + message.getContent() + "' For '" + member.getEffectiveName() + "'.");
arguments.remove(0);
command.execute(textChannel, member, message, arguments);
DiscordBot.getInstance().getDiscord().getMessageSender().addMessage(message);
return;
}
}
}
use of io.github.lxgaming.discordbot.entries.ICommand in project DiscordBot by LXGaming.
the class HelpCommand method execute.
@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.DEFAULT);
embedBuilder.setTitle("Commands", null);
for (Iterator<ICommand> iterator = DiscordBot.getInstance().getDiscord().getCommand().getRegisteredCommands().iterator(); iterator.hasNext(); ) {
ICommand command = iterator.next();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Description - " + command.getDescription() + "\n");
stringBuilder.append("Usage - " + command.getUsage() + "\n");
if (command.getAliases() != null && !command.getAliases().isEmpty()) {
stringBuilder.append("Aliases - " + String.join(", ", command.getAliases()));
}
embedBuilder.addField(command.getName(), stringBuilder.toString(), false);
}
embedBuilder.setFooter("<> = Required Argument, [] = Optional Argument", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
Aggregations