Search in sources :

Example 1 with Emote

use of net.dv8tion.jda.api.entities.Emote in project Saber-Bot by notem.

the class VerifyUtilities method verifyEmoji.

/**
 * verify that a supplied emoji string is a valid discord emoji
 * @param emoji emoji string (either raw emoji char or discord emoji ID)
 * @return true if valid
 */
public static boolean verifyEmoji(String emoji) {
    if (!EmojiManager.isEmoji(emoji)) {
        // split on colons to isolate the reaction name from it's ID
        String[] split = emoji.split(":");
        // trim to include only the ID
        String emoteId = split[split.length - 1].replaceAll("[^\\d]", "");
        Emote emote = null;
        try {
            for (JDA jda : Main.getShardManager().getShards()) {
                emote = jda.getEmoteById(emoteId);
                if (emote != null)
                    break;
            }
        } catch (Exception e) {
            return false;
        }
        if (emote == null) {
            return false;
        }
    }
    return true;
}
Also used : JDA(net.dv8tion.jda.api.JDA) Emote(net.dv8tion.jda.api.entities.Emote)

Aggregations

JDA (net.dv8tion.jda.api.JDA)1 Emote (net.dv8tion.jda.api.entities.Emote)1