Discord.jschannels.create不是构造函数

我一直在制作一个机器人,当成员对消息做出反应时,它会创建一个支持频道。它发送一个嵌入等待反应就好了,但是当我对应该为我创建一个新频道的消息做出反应时,它会抛出一个错误,说Uncaught TypeError: guild.channels.create is not a constructor. 它不会告诉它从哪条线抛出。

这是引发错误的代码块:

} else if(reaction.message.channel.id == supportChannelID){
        console.log('support');
        if(reaction.emoji.name== ''){
            let guild = reaction.message.guild;
            let supportChannel = new guild.channels.create(`Podpora - ${user.username}`)
                type: text,
                supportChannel.overwritePermissions([
                {
                    id: memberRole,
                    deny: ['VIEW_CHANNEL'],
                },
                {
                    id: user.id,
                    allow: ['VIEW_CHANNEL'],
                    allow: ['SEND_MESSAGES'],
                    allow: ['READ_MESSAGE_HISTORY'],
                    allow: ['ATTACH_FILES'],
                },
                ])
            console.log('created channel');
            let supportChannelEmbed = new Discord.MessageEmbed()
                .setColor(1752220)
                .setAuthor("Azuremic", "https://i.imgur.com/m4hkkIj.png")
                .addFields(
                    {name: `Podpora ${user.username}`, value: 'Po?kej na n?koho z Admin Teamu prosím'}
                )
                .setFooter("Reaguj pomocí ? ke smazání channelu")
                client.channels.cache.get(supportChannel).send(supportChannelEmbed).then(supportChannelEmbed.react('?'));
                console.log('sent support embed');
            client.on('messageReactionAdd', (reaction, user) =>{
                if(user.bot) return;
                if(reaction.message.channel.id == supportChannel.id){
                    if(reaction === '?'){
                        supportChannel.delete();
                    }
                }
            });
        }
    }


回答

由于错误提到guild.channels.create不是构造函数,因此您不应使用new关键字。

此外,还有更多错误,要修复它们,请参阅下面的代码段:

let supportChannel = await guild.channels.create(`Podpora - ${user.username}`, {
  type: 'text',
  permissionOverwrites: [
    {
      id: memberRole,
      deny: ['VIEW_CHANNEL'],
    },
    {
      id: user.id,
      allow: ['VIEW_CHANNEL'],
      allow: ['SEND_MESSAGES'],
      allow: ['READ_MESSAGE_HISTORY'],
      allow: ['ATTACH_FILES'],
    },
  ],
});

你不应该client.on('messageReactionAdd')在你的命令处理程序中使用


以上是Discord.jschannels.create不是构造函数的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>