admin管理员组文章数量:1244272
Well, I'm currently using the emoji :x:, but on my server I have an emoji called :superbotxemoji: I just don't know how I get my bot to use it
My code:
const Discord = require('discord.js');
module.exports = {
name: 'say',
description: 'say',
execute(message, args) {
const { prefix, token } = require('../config.json');
if (!message.member.hasPermission('ADMINISTRATOR'))
return message.channel.send({
embed: {
color: 16777201,
description: `:x: | ${message.author}, You are not allowed to use this mand.`,
footer: {
text: ` | Required permission: ADMINISTRATOR`,
},
},
});
if (!args.length)
return message.channel.send({
embed: {
color: 16777201,
description: `:x: | ${message.author}, You need to put a message.`,
footer: {
text: ` | Example: !say hello`,
},
},
});
const sayMessage = args.join(' ');
message.delete({ timeout: 1 });
message.channel.send(sayMessage);
},
};
Well, I'm currently using the emoji :x:, but on my server I have an emoji called :superbotxemoji: I just don't know how I get my bot to use it
My code:
const Discord = require('discord.js');
module.exports = {
name: 'say',
description: 'say',
execute(message, args) {
const { prefix, token } = require('../config.json');
if (!message.member.hasPermission('ADMINISTRATOR'))
return message.channel.send({
embed: {
color: 16777201,
description: `:x: | ${message.author}, You are not allowed to use this mand.`,
footer: {
text: ` | Required permission: ADMINISTRATOR`,
},
},
});
if (!args.length)
return message.channel.send({
embed: {
color: 16777201,
description: `:x: | ${message.author}, You need to put a message.`,
footer: {
text: ` | Example: !say hello`,
},
},
});
const sayMessage = args.join(' ');
message.delete({ timeout: 1 });
message.channel.send(sayMessage);
},
};
Share
Improve this question
edited Sep 22, 2020 at 15:34
Lioness100
8,4126 gold badges20 silver badges50 bronze badges
asked Sep 2, 2020 at 12:05
SrVertiguSrVertigu
831 gold badge2 silver badges5 bronze badges
1 Answer
Reset to default 11There is actually a very detailed explanation from the official discord.js
guide which you can find here, although I'll try to paraphrase it.
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.
This will result in the emojis unique ID
in this format: <:emoji-name:emoji-id>
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.
On the other hand, there's another very easy way to get an emoji using the client.emojis.cache
collection and the .find()
method.
client.emojis.cache.find(emoji => emoji.name === '<name of emoji>')
This method will also make it possible to send custom emojis, however, this time you can find them by name. Be careful, if there are more than one emojis by the given name, it will not work.
A way to bypass this problem would be looking at a guild.emojis.cache
collection. This way the amount of possible duplicate emojis would be narrowed down.
本文标签: javascriptHow to make the bot send personalized emojisStack Overflow
版权声明:本文标题:javascript - How to make the bot send personalized emojis? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740201181a2240242.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论