【问题标题】:Discord Bot Cannot read property 'size' of undefinedDiscord Bot 无法读取未定义的属性“大小”
【发布时间】:2020-06-20 19:47:20
【问题描述】:

Discord Bot[discord.js V 12]

async execute(client,message,args,dbl,queue,messagecounter) {
  const Discord = require('discord.js')

    const embed1 = new Discord.MessageEmbed()
    .addFields(
    {name: 'Connected Users', value: message.guild.me.voice.channel.members.cache.size, inline: true})
     message.channel.send(embed1)
};

请帮助我如何解决此错误 错误:

Cannot read property 'size' of undefined

【问题讨论】:

    标签: javascript node.js discord.js


    【解决方案1】:

    似乎错误来自这一行:

    message.guild.me.voice.channel.members.cache.size

    您可能应该检查以确保您传递的消息对象具有您正在访问的属性。如果您正在使用具有不确定属性的对象,则应检查该属性是否存在,以及是否未将其设置为某个默认值。

    【讨论】:

      猜你喜欢
      • 2021-08-29
      • 1970-01-01
      • 2021-03-31
      • 2020-10-15
      • 2021-09-14
      • 2021-02-01
      • 2021-02-22
      • 2021-01-08
      • 2021-10-23
      相关资源
      最近更新 更多