【问题标题】:discord.js v13 TypeError: Cannot read property 'createMessageCollector' of undefineddiscord.js v13 TypeError:无法读取未定义的属性“createMessageCollector”
【发布时间】:2021-11-23 16:46:17
【问题描述】:

自从我更新到 discord.js v13 后,我一直收到错误消息。谁能帮帮我?

错误:

TypeError: Cannot read property 'createMessageCollector' of undefined

代码:

        var TitleEmbed = new Discord.MessageEmbed()
            .setColor(Color.general)
            .setTitle(`${Mode} Post Title`)
            .setDescription(`Please enter a title for your post, it should summarise your description in a few words. If selling, you should also include whether you're for hire, or selling assets.`);
        const TitleEmbedSent = await Message.author.send({ embeds: [TitleEmbed] }).then(msg => msg.channel).catch(() => {
            return Message.channel.send(`Sorry ${Message.author}, but I couldn't direct Message you!`)
        });
        const Collector = TitleEmbedSent.channel.createMessageCollector({ MessageFilter, max: 1, time: 300000 });

【问题讨论】:

    标签: node.js discord.js


    【解决方案1】:

    我会继续前进

    var TitleEmbed = new Discord.MessageEmbed()
                .setColor(Color.general)
                .setTitle(`${Mode} Post Title`)
                .setDescription(`Please enter a title for your post, it should summarise your description in a few words. If selling, you should also include whether you're for hire, or selling assets.`);
            try {
                Message.author.send({ embeds: [TitleEmbed] }).then(msg => {
                     const collector = msg.channel.createMessageCollector({ MessageFilter, max: 1, time: 300000 }));
                });
            } catch (err) {
                return Message.channel.send(`Sorry ${Message.author}, but I couldn't direct Message you!`);
            }
    

    你的代码的问题是你用message.channel声明了变量TitleEmbedSent,这在这段代码中显然意味着DMChannel,这很好,但是当你去创建你的MessageCollector时,你会尝试通过做再次找到.channel

    const Collector = TitleEmbedSent.channel.createMessageCollector({ MessageFilter, max: 1, time: 300000 });
    

    TitleEmbed 已经是一个频道,您无法从channel 中获取channel

    【讨论】:

      猜你喜欢
      • 2021-12-31
      • 1970-01-01
      • 2022-01-13
      • 2021-09-25
      • 2021-11-19
      • 1970-01-01
      • 1970-01-01
      • 2023-01-14
      • 2020-07-14
      相关资源
      最近更新 更多