Search in sources :

Example 1 with Emoji

use of com.vdurmont.emoji.Emoji in project BoltBot by DiscordBolt.

the class ChannelUtil method addReaction.

/**
 * Adds a reaction to the message
 *
 * @param m   The message to add to
 * @param es2 The reaction list to add
 */
public static void addReaction(IMessage m, Emoji[] es2) {
    List<Emoji> es1 = Arrays.asList(es2);
    Collections.reverse(es1);
    Emoji[] es = (Emoji[]) es1.toArray();
    final AtomicInteger i = new AtomicInteger();
    RequestBuffer.request(() -> {
        for (; i.get() < es.length; i.incrementAndGet()) {
            if (es[i.intValue()] != null) {
                m.addReaction(es[i.intValue()]);
            }
        }
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Emoji(com.vdurmont.emoji.Emoji)

Example 2 with Emoji

use of com.vdurmont.emoji.Emoji 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

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