discord.js:无法读取未定义的属性“通道”

时间:2021-05-01 17:25:27

标签: javascript node.js discord discord.js

我在 Node.js 中开发票务系统,但总是收到以下错误:

<块引用>

类型错误:无法读取未定义的属性“channels”

这很奇怪,我也查了文档也没找到。

我的代码是:

module.exports = {
    name: "ticket2",
    aliases: [],
    permissions: [],
    description: "open a ticket!",
    async execute(message, args, cmd, client, discord) {
        const channel = await message.guild.channels.create(`ticket: ${message.author.tag}`);

        channel.setParent("761885375424888862");

        channel.updateOverwrite(message.guild.id, {
            SEND_MESSAGE: false,
            VIEW_CHANNEL: false,
        });
        channel.updateOverwrite(message.author, {
            SEND_MESSAGE: true,
            VIEW_CHANNEL: true,
        });

        const reactionMessage = await channel.send(
            `${message.author}, welcome to your ticket!\nHere you can:\n:one: Report an issue or bug of the server.\n:two: Suggest any idea for the server.\n:three: Report a staff member of the server.\n\nMake sure to be patient, support will be with you shortly.`
        );

        try {
            await reactionMessage.react("?");
            await reactionMessage.react("⛔");
        } catch (err) {
            channel.send("Error sending emojis!");
            throw err;
        }

        const collector = reactionMessage.createReactionCollector((reaction, user) => message.guild.members.cache.find((member) => member.id === user.id).hasPermission("ADMINISTRATOR"), { dispose: true });

        collector.on("collect", (reaction, user) => {
            switch (reaction.emoji.name) {
                case "?":
                    channel.updateOverwrite(message.author, { SEND_MESSAGES: false });
                    break;
                case "⛔":
                    channel.send("Deleting this channel in 5 seconds!");
                    setTimeout(() => channel.delete(), 5000);
                    break;
            }
        });

        message.channel
            .send(`We will be right with you! ${channel}`)
            .then((msg) => {
                setTimeout(() => msg.delete(), 7000);
                setTimeout(() => message.delete(), 3000);
            })
            .catch((err) => {
                throw err;
            });
    },
};

我做错了什么?请帮助<3

0 个答案:

没有答案