错误覆盖权限

时间:2020-06-19 12:01:25

标签: javascript node.js discord.js

message.guild.channels.create(`ticket-${message.author.username}`).then
            (channel => channel.overwritePermissions(Support, {
                            SEND_MESSAGES: true,
                            READ_MESSAGES: true
                        }));
                    channel.overwritePermissions(everyone, {
                            SEND_MESSAGES: false,
                            READ_MESSAGES: false
                        });
                    channel.overwritePermissions(message.author, {
                            SEND_MESSAGES: true,
                            READ_MESSAGES: true
                    }); {

                      }

创建频道时我不知道如何添加权限,有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

第一个错误是您正在使用Supporteveryonemessage.author,这些都必须是引用角色ID或成员ID的ID

这不是错误的一部分,但是由于您询问:如果查看<GuildChannelManager>.create()的文档,您会看到第二个参数是可以指定permissionOverwrites的选项,因此您可以而不是修改.then

中的覆盖

https://discord.js.org/#/docs/main/stable/class/GuildChannelManager?scrollTo=create

msg.guild.channels.create(`ticket-${message.author.username}`, {
  type: 'text',
  permissionOverwrites: [
     {
       id: "SUPPORT_ROLE_ID",
       allow: ['SEND_MESSAGES', 'READ_MESSAGES'],
    },
    {
       id: message.author.id,
       allow: ['SEND_MESSAGES', 'READ_MESSAGES'],
    },
    {
       id: message.guild.roles.everyone.id,
       allow: ['SEND_MESSAGES', 'READ_MESSAGES'],
    }
  ],
});