如何使机器人发送个性化的表情符号? [英] How to make the bot send personalized emojis?
问题描述
好吧,我目前正在使用表情符号:x:,但是在我的服务器上,我有一个名为:superbotxemoji 的表情符号:我只是不知道我该怎么做让我的机器人来使用它
我的代码:
const Discord = require('discord.js');module.exports = {名称:"say",描述:说",执行(消息,args){const {prefix,token} = require('../config.json');如果(!message.member.hasPermission('ADMINISTRATOR'))返回message.channel.send({嵌入:{颜色:16777201,说明:`:x:|$ {message.author},不允许使用此命令.页脚:{文字:`|所需权限:ADMINISTRATOR`,},},});如果(!args.length)返回message.channel.send({嵌入:{颜色:16777201,说明:`:x:|$ {message.author},您需要输入一条消息.页脚:{文字:`|例如:!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:
There is actually a very detailed explanation from the official To send a custom emoji, you must get that emoji's unique This will result in the emojis unique 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 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 这篇关于如何使机器人发送个性化的表情符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! discord.js
指南中有非常详细的解释,您可以找到集合和 client.emojis.cache.find(emoji => emoji.name ==='< emoji名称>')
guild.emojis.cache
集合.这样,可以缩小可能重复的表情符号的数量.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 command.`,
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);
},
};
discord.js
guide which you can find here, although I'll try to paraphrase it.ID
. To find that, you must send the emote in discord with a backslash in front of it; essentially escaping the emoji.ID
in this format: <:emoji-name:emoji-id>
client.emojis.cache
collection and the .find()
method.client.emojis.cache.find(emoji => emoji.name === '<name of emoji>')
guild.emojis.cache
collection. This way the amount of possible duplicate emojis would be narrowed down.