Search in sources :

Example 11 with XEmbedBuilder

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

the class Command method getCommandInfo.

/**
 * Creates a message used to fetch the command's documentations
 *
 * @param command
 * @return
 */
public XEmbedBuilder getCommandInfo(CommandObject command) {
    XEmbedBuilder infoEmbed = new XEmbedBuilder(command);
    // command info
    StringBuilder builder = new StringBuilder();
    builder.append(description(command) + "\n");
    builder.append("**Type: **" + type.toString() + ".");
    // display permissions
    if (perms != null && perms.length != 0) {
        builder.append("\n**Perms: **");
        ArrayList<String> permList = new ArrayList<>(perms.length);
        for (Permissions p : perms) {
            permList.add(Utility.enumToString(p));
        }
        builder.append(Utility.listFormatter(permList, true));
    }
    if (names.length > 1) {
        List<String> aliases = Arrays.asList(names).stream().map(s -> command.guild.config.getPrefixCommand() + s).collect(Collectors.toList());
        aliases.remove(0);
        builder.append("\n**Aliases:** " + Utility.listFormatter(aliases, true));
    }
    List<SubCommandObject> objectList = subCommands.stream().filter(subCommandObject -> GuildHandler.testForPerms(command, subCommandObject.getPermissions())).collect(Collectors.toList());
    if (objectList.size() != 0)
        builder.append("\n" + Command.spacer);
    infoEmbed.withTitle("> Help - " + names()[0]);
    infoEmbed.appendField("**" + getUsage(command) + "**    " + Command.spacer, builder.toString(), true);
    for (SubCommandObject s : objectList) {
        infoEmbed.appendField(s.getCommandUsage(command) + "    " + Command.spacer, s.getHelpDesc(command), true);
    }
    // Handle channels
    List<IChannel> channels = command.guild.getChannelsByType(channel);
    List<String> channelMentions = Utility.getChannelMentions(channels);
    // channel
    if (channelMentions.size() > 0) {
        if (channelMentions.size() == 1) {
            infoEmbed.appendField("Channel ", Utility.listFormatter(channelMentions, true), false);
        } else {
            infoEmbed.appendField("Channels ", Utility.listFormatter(channelMentions, true), false);
        }
    }
    return infoEmbed;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) Arrays(java.util.Arrays) CommandObject(com.github.vaerys.commands.CommandObject) Globals(com.github.vaerys.main.Globals) Logger(org.slf4j.Logger) ChannelSetting(com.github.vaerys.enums.ChannelSetting) LoggerFactory(org.slf4j.LoggerFactory) SAILType(com.github.vaerys.enums.SAILType) GuildHandler(com.github.vaerys.handlers.GuildHandler) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) SubCommandObject(com.github.vaerys.objects.SubCommandObject) List(java.util.List) IChannel(sx.blah.discord.handle.obj.IChannel) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject) Permissions(sx.blah.discord.handle.obj.Permissions) Pattern(java.util.regex.Pattern) LinkedList(java.util.LinkedList) Utility(com.github.vaerys.main.Utility) XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) IChannel(sx.blah.discord.handle.obj.IChannel) ArrayList(java.util.ArrayList) Permissions(sx.blah.discord.handle.obj.Permissions) SubCommandObject(com.github.vaerys.objects.SubCommandObject)

Example 12 with XEmbedBuilder

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

the class GuildToggle method info.

public XEmbedBuilder info(CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    if (isModule()) {
        builder.withTitle("Module - " + name());
    } else {
        builder.withTitle("Setting - " + name());
    }
    String fullDesc = desc(command);
    if (statsOnInfo()) {
        String stats = stats(command);
        if (stats != null && !stats.isEmpty()) {
            fullDesc += "\n\n**Stats:**\n" + stats;
        }
    }
    builder.withDesc(fullDesc);
    List<String> commandNames = commands.stream().map(command1 -> command1.getCommand(command)).collect(Collectors.toList());
    commandNames.addAll(Globals.getAllCommands().stream().filter(command1 -> command1.type() == affectsType).map(command1 -> command1.getCommand(command)).collect(Collectors.toList()));
    commandNames = commandNames.stream().distinct().collect(Collectors.toList());
    List<SAILType> settingNames = settings.stream().map(guildSetting -> guildSetting.name()).collect(Collectors.toList());
    List<ChannelSetting> channelNames = channels.stream().map(channelSetting -> channelSetting).collect(Collectors.toList());
    if (commandNames.size() != 0) {
        builder.appendField("Commands:", "```\n" + Utility.listFormatter(commandNames, true) + Command.spacer + "```", true);
    }
    if (settingNames.size() != 0) {
        builder.appendField("Settings:", "```\n" + Utility.listEnumFormatter(settingNames, true) + Command.spacer + "```", true);
    }
    if (channelNames.size() != 0) {
        builder.appendField("Channels:", "```\n" + Utility.listEnumFormatter(channelNames, true) + Command.spacer + "```", true);
    }
    StringBuilder footer = new StringBuilder();
    if (isModule())
        footer.append("Module ");
    else
        footer.append("Setting ");
    if (enabled(command.guild.config))
        footer.append("Enabled.");
    else
        footer.append("Disabled.");
    builder.withFooterText(footer.toString());
    return builder;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) List(java.util.List) CommandObject(com.github.vaerys.commands.CommandObject) Globals(com.github.vaerys.main.Globals) GuildObject(com.github.vaerys.masterobjects.GuildObject) GuildConfig(com.github.vaerys.pogos.GuildConfig) ChannelSetting(com.github.vaerys.enums.ChannelSetting) SAILType(com.github.vaerys.enums.SAILType) Utility(com.github.vaerys.main.Utility) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) ChannelSetting(com.github.vaerys.enums.ChannelSetting) SAILType(com.github.vaerys.enums.SAILType)

Example 13 with XEmbedBuilder

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

the class SlashCommand method getCommandInfo.

@Override
public XEmbedBuilder getCommandInfo(CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle(getCommand(command));
    builder.withDescription(description(command));
    if (names.length != 1) {
        builder.appendField("Aliases:", Utility.listFormatter(Arrays.asList(names), true), true);
    }
    return builder;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

Example 14 with XEmbedBuilder

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

the class BotHelp method tags.

private String tags(CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle("Tags.");
    builder.withDesc("> Tags are strings of text that when added to CustomCommands, The info page generator, Daily Messages or Level up messages run specific code and change the output text.");
    builder.send(command.channel);
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

Example 15 with XEmbedBuilder

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

the class BotHelp method directMessages.

private String directMessages(CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle("Direct messages.");
    builder.withDesc("> When you send a non command Direct message to " + command.client.bot.displayName + " it will send it to the bot developer.");
    builder.send(command.channel);
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

Aggregations

XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)51 ArrayList (java.util.ArrayList)15 ChannelSetting (com.github.vaerys.enums.ChannelSetting)10 SAILType (com.github.vaerys.enums.SAILType)10 CommandObject (com.github.vaerys.commands.CommandObject)9 IUser (sx.blah.discord.handle.obj.IUser)9 Utility (com.github.vaerys.main.Utility)8 UserObject (com.github.vaerys.masterobjects.UserObject)8 Collectors (java.util.stream.Collectors)8 Command (com.github.vaerys.templates.Command)7 List (java.util.List)6 Permissions (sx.blah.discord.handle.obj.Permissions)6 RequestHandler (com.github.vaerys.handlers.RequestHandler)5 StringHandler (com.github.vaerys.handlers.StringHandler)5 ProfileObject (com.github.vaerys.objects.ProfileObject)5 IRole (sx.blah.discord.handle.obj.IRole)5 CCommandObject (com.github.vaerys.objects.CCommandObject)4 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)4 GuildToggle (com.github.vaerys.templates.GuildToggle)4 LinkedList (java.util.LinkedList)4