Search in sources :

Example 6 with SubCommandObject

use of com.github.vaerys.objects.SubCommandObject in project DiscordSailv2 by Vaerys-Dawn.

the class Command method isName.

public boolean isName(String args, CommandObject command) {
    String prefix = command.guild.config.getPrefixCommand();
    List<String> allNames = new ArrayList<>(Arrays.asList(names));
    for (SubCommandObject s : subCommands) {
        if (GuildHandler.testForPerms(command, s.getPermissions())) {
            allNames.addAll(Arrays.asList(s.getNames()));
        }
    }
    allNames = allNames.stream().distinct().collect(Collectors.toList());
    for (String s : allNames) {
        if (s.equalsIgnoreCase(args) || args.equalsIgnoreCase(prefix + s)) {
            return true;
        }
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) SubCommandObject(com.github.vaerys.objects.SubCommandObject)

Aggregations

SubCommandObject (com.github.vaerys.objects.SubCommandObject)6 ArrayList (java.util.ArrayList)4 Command (com.github.vaerys.templates.Command)3 Permissions (sx.blah.discord.handle.obj.Permissions)3 CommandObject (com.github.vaerys.commands.CommandObject)2 ChannelSetting (com.github.vaerys.enums.ChannelSetting)2 SAILType (com.github.vaerys.enums.SAILType)2 GuildHandler (com.github.vaerys.handlers.GuildHandler)2 Globals (com.github.vaerys.main.Globals)2 Utility (com.github.vaerys.main.Utility)2 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)2 Collectors (java.util.stream.Collectors)2 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)1 java.util (java.util)1 Arrays (java.util.Arrays)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Pattern (java.util.regex.Pattern)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Logger (org.slf4j.Logger)1