react 按钮工作正常,但唯一的问题是它在嵌入消息中显示自定义表情符号的 ID。
这是代码:
{name: 'reactionrole',
description: "Sets up a reaction role message!",
async execute(message, args, Discord, client) {
const channel = '866637673937895457';
const redTeamRole = message.guild.roles.cache.find(role => role.name === "Red");
const yellowTeamRole = message.guild.roles.cache.find(role => role.name === "Yellow");
const RandomTeamRole = message.guild.roles.cache.find(role => role.name === "olddrawinlmaooo");
const redTeamEmoji = '🍉';
const yellowTeamEmoji = '🍋';
const RandomTeamEmoji = '889108655344091156';
let embed = new Discord.MessageEmbed()
.setColor('#e42643')
.setTitle('Choose a team to play on!')
.setDescription('Choosing a team will allow you to interact with your teammates!\n\n'
+ `${redTeamEmoji} for yellow team\n`
+ `${yellowTeamEmoji} for blue team\n`
+ `${RandomTeamEmoji} for random team`);
let messageEmbed = await message.channel.send(embed);
messageEmbed.react(redTeamEmoji);
messageEmbed.react(yellowTeamEmoji);
messageEmbed.react(RandomTeamEmoji);
client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.id == channel) {
if (reaction.emoji.name === redTeamEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(redTeamRole);
}
if (reaction.emoji.name === yellowTeamEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(yellowTeamRole);
}
if (reaction.emoji.name === RandomTeamEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(RandomTeamRole);
}
} else {
return;
}
});
client.on('messageReactionRemove', async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.id == channel) {
if (reaction.emoji.name === redTeamEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(redTeamRole);
}
if (reaction.emoji.name === yellowTeamEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(yellowTeamRole);
}
if (reaction.emoji.name === RandomTeamEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(RandomTeamRole);
}
} else {
return;
}
});
}
} }
最佳答案
用表情符号名称和 ID 替换 ID。它看起来像这样:<:yeah:735918408561852457>
为了轻松获得它,只需在您想要的表情符号前面放一个\,然后将其发送到 channel 中,它就会为您提供那种格式。
关于javascript - 自定义表情符号 react 角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69637436/