Search in sources :

Example 36 with XEmbedBuilder

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

the class ListJoinMessages method execute.

@Override
public String execute(String args, CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    StringHandler handler = new StringHandler();
    List<JoinMessage> messages = command.guild.channelData.getJoinMessages();
    if (messages.size() == 0) {
        return "> No Messages exist right now, you can create some with **" + new NewJoinMessage().getUsage(command) + "**";
    }
    int page = 1;
    try {
        page = Integer.parseInt(args);
        if (page <= 0)
            return "> Invalid Page.";
    } catch (NumberFormatException e) {
        if (args != null && !args.isEmpty()) {
            return "> Not a valid number";
        }
    }
    page--;
    List<String> pages = new LinkedList<>();
    int index = 1;
    int i = 0;
    for (JoinMessage m : messages) {
        if (i == 10) {
            i = 0;
            pages.add(handler.toString());
            handler.emptyContent();
        }
        String shortNote = Utility.truncateString(Utility.removeFun(m.getContent()), 65);
        handler.append("**> Message #" + index + "**");
        handler.append("\n" + shortNote);
        handler.append("\n");
        i++;
        index++;
    }
    pages.add(handler.toString());
    if (page >= pages.size()) {
        return "> Invalid Page.";
    }
    builder.withTitle("> Join Message list");
    builder.withDesc(pages.get(page) + "\n\n" + missingArgs(command));
    builder.withFooterText("Page " + (page + 1) + "/" + pages.size() + " | Total Join Messages: " + messages.size());
    builder.send(command.channel);
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) JoinMessage(com.github.vaerys.objects.JoinMessage) StringHandler(com.github.vaerys.handlers.StringHandler) LinkedList(java.util.LinkedList)

Example 37 with XEmbedBuilder

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

the class BotHelp method arguments.

private String arguments(CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle("Arguments.");
    builder.withDesc("> `[]` and `()` in the command usage are not needed and in most cases can cause the command to fail.\n" + "> `[]` brackets means that this argument is required.\n" + "> `()` brackets means that this argument is optional.\n" + "> When an argument ends in `...` it means you can input as many of this argument as you like.\n" + "> The `@User` argument means that you can either use a user ID, mention or the user's display name or username as an argument.\n" + "> The `Time` argument means that you can enter a number or a number ending in `d` for days, `h` for hours, `m` for minutes or `s` for seconds.");
    builder.send(command.channel);
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

Example 38 with XEmbedBuilder

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

the class BotHelp method defaultOutput.

private String defaultOutput(CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle("Bot Help.");
    builder.withDesc("**Modes:**\n" + "> **Arguments**\n" + "Gives you information about how to use command arguments.\n" + "> **DMs**\n" + "Gives you information about how Direct messages work for **" + command.client.bot.displayName + "**.\n" + "> **Tags**\n" + "Gives you information explaining what tags are.\n\n" + missingArgs(command));
    builder.send(command.channel);
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

Example 39 with XEmbedBuilder

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

the class GetGuildInfo method resetEmbed.

private XEmbedBuilder resetEmbed(XEmbedBuilder builder, IChannel channel, CommandObject command, int extraLength) {
    if ((builder.getTotalVisibleCharacters() + extraLength) > 2000 || builder.getFieldCount() + 1 > EmbedBuilder.FIELD_COUNT_LIMIT) {
        RequestHandler.sendEmbedMessage("", builder, channel).get();
        builder = new XEmbedBuilder(command);
    }
    return builder;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

Example 40 with XEmbedBuilder

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

the class TagObject method getInfo.

public XEmbedBuilder getInfo(CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle(name);
    StringBuilder descContents = new StringBuilder();
    descContents.append(desc);
    if (isPassive()) {
        descContents.append("\n\n**This tag cannot be used in commands and is passively run on every command.**");
    } else if (requiredArgs != 0) {
        descContents.append("\n**Usage:** " + "`" + prefix + usage + suffix + "`");
    } else {
        descContents.append("\n**Usage:** `" + name + "`");
    }
    descContents.append("\n\n**Types:** " + Utility.listEnumFormatter(types, true));
    builder.withDesc(descContents.toString());
    return builder;
}
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