I want to know the code to get the CDN link of discord.js v12 emoji.

Asked 2 years ago, Updated 2 years ago, 35 views

Like Mini Kuda, we are trying to create a bot that recognizes when a user uses an emoji and converts the emoji to an address and sends a message (not embedded, just a link).

Official discode.I'm trying to implement it with the .url in the js document, but I can't think of how to code it ㅠ<

If a user writes an emoji, {
 Emoji recognition, change that emoji to url
 channel.send(emoji).url);
}

That's what I think. I'm asking because there's no example code like that even if I google it ㅠ<

javascript node.js

2022-09-20 22:02

1 Answers

I solved it.

// Emoji to image
  client.on("message", async message => {
    if (message.author.bot) return;

  const args = message.content.trim().split(/ +/g);
  let emoji = args[0];
  emoji = emoji.substring(3, emoji.length - 1);

  const emojiarray = emoji.split(':');

  const botemoji = client.emojis.cache.get(emojiarray[1]);

  if(!botemoji) {
    if (message.author.bot) return;
  } } else {
   await message.channel.send({files: [
    {
      attachment: botemoji.url,
      name: botemoji.name + '.png'
    }
  ]});
  message.delete();
}
 {
    if (message.author.bot) return;
  } } else {

The reason why I added the part is that when I posted the message, the bot mistook it for emoji, so I changed it temporarily.


2022-09-20 22:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.