无法读取属性';角色';未定义discord.js v12的

无法读取属性';角色';未定义discord.js v12的,discord.js,Discord.js,我希望机器人给反应者一个角色。但它不起作用。有人知道问题出在哪里吗?discord.js v12中的Im编码 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 (

我希望机器人给反应者一个角色。但它不起作用。有人知道问题出在哪里吗?discord.js v12中的Im编码

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);

尝试将
反应
更改为
消息

let role=message.guild.roles.cache.find(role=>role.id=='753290549548679229');

我认为
reaction.guild
不是有效的功能

尝试将
reaction
更改为
消息

let role=message.guild.roles.cache.find(role=>role.id=='753290549548679229');

我认为,
reaction.guild
不是一个有效的函数

我将其更改为:

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');

我将其改为:

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');

不,它仍然不起作用。控制台给我这个错误:“ReferenceError:message未定义”您没有定义message,您使用的是命令处理程序还是
client.on('message')…
?确保您在消息事件中传递了
消息
,然后出现此错误:无法读取未定义的
reaction.message.guild的属性“guild”。guild
不工作。控制台给我这个错误:“ReferenceError:message未定义”您没有定义message,您使用的是命令处理程序还是
client.on('message')…
?确保您在消息事件中传递的是
消息,然后出现此错误:无法读取未定义的
反应的属性“guild”。message.guild
确保
成员是
GuildMember
属性的成员,而不是
用户
属性确保
成员是
GuildMember
属性而非
用户
属性