我希望机器人给反应堆一个角色。但它不起作用。有人知道问题出在哪里吗?我在discord.js v12中编码
if (user.bot) return;
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.guild.id !== "753289194738024632") return;
if (reaction.message.channel.id === "753290581412937832") {
const cs = bot.emojis.cache.find(emoji => emoji.name === "csgo");
const vl = bot.emojis.cache.find(emoji => emoji.name === "valorant");
const fn = bot.emojis.cache.find(emoji => emoji.name === "fortnite");
let role = reaction.guild.roles.cache.find(role => role.id === '753290549548679229');
member.roles.add(role.id);
答案 0 :(得分:1)
尝试将reaction
更改为message
let role = message.guild.roles.cache.find(role => role.id === '753290549548679229');
我认为reaction.guild
不是有效函数
答案 1 :(得分:1)
我将其更改为:
if(message.channel.type === 'dm') return message.reply('This command does not work in DMs') //checks if the command wasnt executed in DMs
let role = message.guild.roles.cache.find(role => role.id === '753290549548679229');