If you type :a: or :gun:, it sends an emote in discord.
What I'm trying to do, is if someone sends just the string that is in between those : (that is, in this case, I showed, 'a' or 'gun'), my bot would analyze it and check if it can be 'translated' to an emote.
I tried to do:
if (msg.content.length === 1)
But msg.content keeps on being :(string): so it doesn't work.
I am currently searching for other ways and will keep this updated. Any tips will be highly appreciated!
Edit: Went with this api as I found no other way
There are a couple caveats with this: 1) There does not appear to be anyway of checking against standard emojis; only guild (i.e. custom) emojis. 2) It may be possible with a 3rd-party plugin.
Regarding #1, this will translate a message into a GUILD emoji:
const emoji = message.guild.emojis.cache.find(e => e.name === message.content);
if (emoji) {
message.channel.send(`<:${emoji.name}:${emoji.id}>`);
}
Regarding #2, check out emoji-regex. From what I can tell, convert the message to an emoji, and compare it to what emoji-regex tells you. If it matches, then you can send the emoji.