Discord.js v12+ TypeError: Cannot read property 'channel' of undefined

Discord.js v12+ TypeError: Cannot read property 'channel' of undefined

所以我正在覆盖票证功能的权限,它给我一个错误

Cannot read property 'channel' of undefined

用这行代码:

    message.guild.channels.create(`create-${message.author.id}`, { type: 'text' }).then(c => {
    c.message.channel.overwritePermissions([
      {
        id: "@everyone",
        deny: ['SEND_MESSAGES', 'READ_MESSAGES'],
      }
    ]);
    c.message.channel.overwritePermissions([
      {
        id: message.author.id,
        allow: ['SEND_MESSAGES', 'READ_MESSAGES'],
      },
    ]);

跟二线八线(又名)有关

c.message.channel.overwritePermissions([

X2

如果我从此删除邮件 属性

c.message.channel.overwritePermissions([

我收到这个错误

TypeError: Cannot read property 'overwritePermissions' of undefined

Channel 没有 message 属性,也没有 channel 属性.


message.guild.channels.create(`create-${message.author.id}`, {
    type: 'text', permissionOverwrites: [
        {
            id: '@everyone',
            deny: ['SEND_MESSAGES', 'VIEW_CHANNEL']
        },
        {
            id: message.author.id,
            allow: ['SEND_MESSAGES', 'VIEW_CHANNEL']
        }
    ]
})

请注意,没有名为 READ_MESSAGES 的权限。相反,使用 VIEW_CHANNEL.