无法读取未定义discord.js的属性“添加”

时间:2020-07-30 18:37:27

标签: javascript discord.js

试图做一个机器人。 !结婚@进行一般聊天,然后被标记的人得到一个嵌入,该嵌入由两个表情符号的选中标记 X 做出反应。按下复选标记后,带标签的人将扮演角色,而消息作者则没有,但他应该。 message.author 让我的用户没有角色,所以说未定义...欢迎任何帮助

const Discord = require('discord.js');
const { getMember } = require("../../functions.js");

module.exports = {
    name: "marry",
    aliases: ["affinity"],
    category: "fun",
    description: "Vedybos",
    usage: "[mention | id | username]",
    run: async (client, message, args) => {
        // Get a member from mention, id, or username

        let person = getMember(message, args[0]);

        if (!person || message.author.id === person.id) {
            person = message.guild.members.cache
                .filter(m => m.id !== message.author.id);
        }

        const embed = new Discord.MessageEmbed()
            .setColor("#ffb6c1")
            .setDescription(`☁ ${message.author} sako: Ar tekėsi už manęs ${message.mentions.members.first()}? :heart:`)
            .setTimestamp();

        var membera = message.mentions.members.first()

        const msgaut = message.author

        message.mentions.users.first().send({embed:embed}).then(embedMessage => {
          embedMessage.react("✅");
          embedMessage.react("❌");
        }).then(client.on('messageReactionAdd', async (reaction, user, guildMember, message) => {
          if (user.bot) return;
          console.log(user.username + " reacted.");
          console.log(user);
          console.log(membera);
          console.log(msgaut);
          console.log(membera.roles);
          console.log(msgaut.roles);
          //console.log(reaction.emoji);
            if (reaction.emoji.name === "✅"){
              console.log(user.username + " ciuvas  mldc");
              membera.roles.add("737958820000694302");
              msgaut.roles.add("737958820000694302");
              user.send("gavai role padla");
              console.log(msgaut);
              msgaut.send("Jis/ji pasakė taip!");
            } else if (reaction.emoji.name === "❌"){
              user.send("Kurwa tu kaip tu galejai!");
              masgaut.send("Jis/ji pasakė ne :(");
            }
        }))


    }
}```

1 个答案:

答案 0 :(得分:0)

您必须将const msgaut = message.author替换为 const msgaut = message.member