Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord.js send emoji

I'm trying to make my bot send an emoji whenever I Type =emoji

I've managed to get everything done but I have no idea how to make the bot send an emoji by the ID of the emoji.

Any help would be appreciated!

like image 998
Retr0 Avatar asked May 23 '20 21:05

Retr0


People also ask

How do you send emojis with a Discord bot?

To send a custom emoji, you must get that emoji's unique ID . To find that, you must send the emote in discord with a backslash in front of it; essentially escaping the emoji. If you paste this special string into a message, the bot will send the emoji. However, the emoji must be from a guild the bot is part of.

How do you respond to discord JS emoji?

To react with an emoji, you need to use the message. react() method. Once you have the emoji character, all you need to do is copy & paste it as a string inside the . react() method!

How do I get emojis on Discord?

How does Discord.js store emojis? There are two places where you can grab emojis using discord.js: in the client, and in the guilds. client.emojis is a collection of every emoji the client has access to, and guild.emojis is a collection of the emojis of a specific guild.

What makes discord JS so good?

It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend. Usability, consistency, and performance are key focuses of discord.js, and it also has nearly 100% coverage of the Discord API.

What is discord bot JS?

Imagine a bot discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.

Is it possible to send custom emojis in DMS?

I have seen bots such as MEE6 that can send custom emojis in DMs, so this surely must be possible. I used .first () since there is only one emoji in the server. Both of these do not work. The emoji will appear in the server it is hosted in, but if I try to send it in any other server, it just shows the emoji name and/or ID.


Video Answer


4 Answers

Do you know the name of the emoji? if so, you can simply do this:

message.channel.send("<:emoji name:emoji id>")

If not, you could possibly do,

const emoji = bot.emojis.cache.get("emoji id")

message.channel.send(`${emoji}`)

I assume the emoji has to be cached for the method above to work, i'm sure someone else could brew up a better solution.

Hope i could help!

like image 166
Genji Avatar answered Oct 22 '22 08:10

Genji


For an animated emoji use <a:EmojiName:EmojiID>

If you don't have Nitro to check the emoji's ID check the guide here

like image 28
Nothingness Avatar answered Oct 22 '22 08:10

Nothingness


You can use

message.channel.send(":emoji name:emoji id")

For if you know the name or the emoji you want

like image 2
Leo Gaunt Avatar answered Oct 22 '22 07:10

Leo Gaunt


Apparently the format has been changed now.

I was able to get it using message.channel.send("Hey! :smiley:") Just like that!

like image 2
Achyut Raj Avatar answered Oct 22 '22 08:10

Achyut Raj