简体   繁体   English

“fn 不是函数” discord.js

[英]“fn is not a function” discord.js

recently I'm having some problems in Discord.js.最近我在 Discord.js 中遇到了一些问题。 I'm not an exper so forgive me if I ask some stuid question.我不是专家,如果我问一些愚蠢的问题,请原谅我。 This is the code:这是代码:

let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0]));
if(!rUser) return message.channel.send('Couldn\'t find this user!');
let rReason = args.join(' ').slice(22);
if(!rReason) return message.channel.send('Insert a reason');

let reportEmbed = new Discord.MessageEmbed()
.setDescription('**User report**')
.addField('Reported user:', `${rUser.displayName} <${rUser.id}>`)
.addField(`Reason:`, `${rReason}`)
.addField('Reported by:', message.author.username)
.setColor(0xf52c2c);

let rChannel = client.channels.cache.get(707956253040574525)
if(!rChannel) return message.channel.send('Not valid report channel');

rChannel.send(reportEmbed)

It gives me this error: TypeError: Cannot read property 'send' of undefined它给了我这个错误: TypeError: Cannot read property 'send' of undefined

I'm using: node.js (6.14.4), discord.js (12.2.0), ms (2.1.2)我正在使用:node.js(6.14.4),discord.js(12.2.0),毫秒(2.1.2)

EDIT编辑

Resolved updating node.js and changing解决了更新 node.js 和更改

let rChannel = message.guild.channels.cache.find(`name`, 'reports')

with

let rChannel = message.guild.channels.cache.find(channel => channel.name === 'reports')

where "reports" is just the name of the channel where the bot will send the message其中“报告”只是机器人将发送消息的通道的名称

You need to update Node.js.您需要更新 Node.js。

Discord.js v12 requires Node.js 12.0.0+. Discord.js v12 需要 Node.js 12.0.0+。

To update Node.js run the following in your terminal:要更新 Node.js,请在终端中运行以下命令:

npm install -g npm stable

npm install -g node

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM