Search in sources :

Example 1 with TagEmbedImage

use of com.github.vaerys.tags.cctags.TagEmbedImage in project DiscordSailv2 by Vaerys-Dawn.

the class RandomCC method execute.

@Override
public String execute(String args, CommandObject command) {
    Random random = new Random();
    int counter = 0;
    List<CCommandObject> commands = command.guild.customCommands.getCommandList();
    CCommandObject randCC = commands.get(random.nextInt(commands.size()));
    while (!command.channel.settings.contains(ChannelSetting.SHITPOST) && randCC.isShitPost() && command.guild.config.shitPostFiltering) {
        if (counter > 25) {
            return "> Your server has way to many shitpost commands, I couldn't find you a normal one.";
        }
        randCC = commands.get(random.nextInt(commands.size()));
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            Utility.sendStack(e);
        }
        counter++;
    }
    String response = randCC.getContents(true);
    for (TagObject t : TagList.getType(TagType.CC)) {
        if (t.name.equals(new TagEmbedImage(0).name)) {
            response = t.handleTag(response + "\n`" + command.guild.config.getPrefixCC() + randCC.getName() + "`", command, args);
        } else {
            response = t.handleTag(response, command, args);
        }
    }
    return response;
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) Random(java.util.Random) TagObject(com.github.vaerys.templates.TagObject) TagEmbedImage(com.github.vaerys.tags.cctags.TagEmbedImage)

Aggregations

CCommandObject (com.github.vaerys.objects.CCommandObject)1 TagEmbedImage (com.github.vaerys.tags.cctags.TagEmbedImage)1 TagObject (com.github.vaerys.templates.TagObject)1 Random (java.util.Random)1