类型错误:无法读取未定义的属性“0”(discord.js)

时间:2021-05-11 17:06:57

标签: discord.js

 const data = suggestedEmbed.embeds[0];

嗨,我遇到了这个错误,我不知道为什么它说上面的代码是问题所在。这个问题有什么解决方案吗?感谢您的阅读。 代码:

module.exports = {
  category: "Utility",
  description: "Accept valid suggestions!",
  expectedArgs: "<messageID> <Reason>",
  minArgs: 2,
  guildOnly: true,
  ownerOnly: true,
  callback:  ({message, args}) => {
    const messageID = args[0]
    const acceptQuery = args.slice(1).join(" ");
    try{
      const suggestionChannel = message.guild.channels.cache.get('834459599699443782');
      const suggestedEmbed = suggestionChannel.messages.fetch(messageID);
      console.log(suggestedEmbed)

      const data = suggestedEmbed.embeds[0];
      const acceptEmbed = new Discord.MessageEmbed()
      .setAuthor(data.author.name, data.author.iconURL())
      .setColor('GREEN')
      .setDescription(data.description)
      .addField("? Status ✅ Accepted! Expect this coming soon!", acceptQuery);

      suggestedEmbed.edit(acceptEmbed);

      const user = client.users.cache.find((u) => u.tag === data.author.name);
      user.send("Your suggestion has been accepted! Thank you for this suggestion, expect this coming soon!")
    } catch(err) {
      console.log(err)
    }
  }
}

0 个答案:

没有答案