Search in sources :

Example 1 with MessageTokenizer

use of sx.blah.discord.util.MessageTokenizer in project DiscordSailv2 by Vaerys-Dawn.

the class SetLevelUpReaction method execute.

@Override
public String execute(String args, CommandObject command) {
    MessageTokenizer messageTokenizer = new MessageTokenizer(command.message.get());
    Emoji emoji = EmojiManager.getByUnicode(new SplitFirstObject(args).getFirstWord());
    IEmoji customEmoji = null;
    if (args.equalsIgnoreCase("Remove")) {
        command.guild.config.levelUpReaction = "null";
        return "> Level Up reaction was removed.";
    }
    if (messageTokenizer.hasNextEmoji()) {
        customEmoji = messageTokenizer.nextEmoji().getEmoji();
    }
    if (emoji == null && customEmoji == null) {
        return "> Not a valid Emoji.";
    } else if (emoji != null) {
        command.guild.config.levelUpReaction = emoji.getUnicode();
        return "> The message a user sent to level up will now be reacted with " + emoji.getUnicode() + ".";
    } else {
        command.guild.config.levelUpReaction = customEmoji.getStringID();
        return "> The message a user sent to level up will now be reacted with " + customEmoji.toString() + ".";
    }
}
Also used : MessageTokenizer(sx.blah.discord.util.MessageTokenizer) IEmoji(sx.blah.discord.handle.obj.IEmoji) Emoji(com.vdurmont.emoji.Emoji) IEmoji(sx.blah.discord.handle.obj.IEmoji) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Aggregations

SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)1 Emoji (com.vdurmont.emoji.Emoji)1 IEmoji (sx.blah.discord.handle.obj.IEmoji)1 MessageTokenizer (sx.blah.discord.util.MessageTokenizer)1