无法读取未定义的属性(Reading' Cache')
它说“无法读取未定义的属性(读取'cache')” 我能做什么?我在代码中犯了一个错误?
这是我的代码
const {MessageEmbed} = require('discord.js')
module.exports = {
name: 'cutem',
execute(client, message, args) {
let member = message.author;
member.roles.cache.has('989342982224355409');
if(!args[0]) return message.reply("send what you want")
let channel = message.mentions.channels.first() || message.channel;
let embed = new MessageEmbed()
.setImage(args[0])
.setColor("GREYPLE")
channel.send(`@here by : <@${message.author.id}>` )
channel.send({embeds: [embed]})
}
}
it said "Cannot read properties of undefined (reading 'cache')"
what i can do? and i did a mistake in the code?
this is my code
const {MessageEmbed} = require('discord.js')
module.exports = {
name: 'cutem',
execute(client, message, args) {
let member = message.author;
member.roles.cache.has('989342982224355409');
if(!args[0]) return message.reply("send what you want")
let channel = message.mentions.channels.first() || message.channel;
let embed = new MessageEmbed()
.setImage(args[0])
.setColor("GREYPLE")
channel.send(`@here by : <@${message.author.id}>` )
channel.send({embeds: [embed]})
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
message.author
返回全局
用户的详细信息,您要做的就是更改您声明用户代码>
没有任何
确实具有您需要的所有属性。因此,要获得角色的对象
属性,因此错误。您实际上需要的是guildmember
guildmemberguildmember
成员
变量的部分:
Using
message.author
returns a globalUser
object which doesn't have anyroles
property, hence the error. What you actually need is aGuildMember
which does have all the properties you need. So to get theGuildMember
details of the user, all you have to do is, change the part where you declare themember
variable from this:to this: