DiscordAPIError:createOverwrite 上缺少访问权限 [英] DiscordAPIError: Missing Access on createOverwrite

查看:11
本文介绍了DiscordAPIError:createOverwrite 上缺少访问权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的机器人用户,拥有除管理员"之外的所有服务器权限,highest.rawPosition 为 18(所有角色中最高的):

My bot user, which has all server permissions except "Administrator", and highest.rawPosition is 18 (highest of all roles) :

user: ClientUser {
    id: 'XXXXXXXXX',
    bot: true,
    username: 'Bot',
    discriminator: '1863',
    avatar: '2e8af5cccdc5cf15a0f88818dbb044e6',
    lastMessageID: null,
    lastMessageChannelID: null,
    verified: true,
    mfaEnabled: true,
    _typing: Map {}
  },

正在尝试添加此角色(rawPosition 为 2):

is trying to add this role (rawPosition is 2) :

Role {
  id: 'XXXXXXXXX',
  name: 'Mod',
  color: 0,
  hoist: false,
  rawPosition: 2,
  permissions: Permissions { bitfield: 37211712 },
  managed: false,
  mentionable: false,
  deleted: false
}

作为对该频道的覆盖权限:

as an overwrite permission to this channel :

CategoryChannel {
  type: 'category',
  deleted: false,
  id: 'XXXXXXXXX',
  name: 'Section Job',
  rawPosition: 6,
  parentID: null,
}

使用此代码:

await channel.createOverwrite(role, {
   VIEW_CHANNEL: true,
   READ_MESSAGES: true,
   SEND_MESSAGES: true,
   CONNECT: true
});

这是我得到的错误:

[2020/10/06 00:52:56:427] DiscordAPIError: Missing Access

我在发布之前进行了搜索.Discord 对这个特定错误给出了许多可能的解释,但没有一个适合我的问题:https://discordjs.guide/popular-topics/permissions-extended.html#missing-permissions

I performed a search before posting this. Discord gives many possible explanations about this specific error, and none would fit with my issue : https://discordjs.guide/popular-topics/permissions-extended.html#missing-permissions

Your bot is missing the needed permission to execute this action in it's calculated base or final permissions (requirement changes based on the type of action you are trying to execute).
--> My bot has all permissions except "Administrator"
You provided an invalid permission number while trying to create overwrites. (The calculator on the apps page returns decimal values while the developer documentation lists the flags in hex. Make sure you are not mixing the two and don't use the hex prefix 0x where not applicable)
--> I give the exact same permissions, formatted exactly the same as another group, and it works
It is trying to execute an action on a guild member with a role higher than or equal to your bots highest role.
--> Not executing an action on a user, but on a group
It is trying to modify or assign a role that is higher than or equal to its highest role.
--> Bot highest role is 18, and added role rawPosition is 2
It is trying to add a managed role to a member.
--> As you can see it is not "managed"
It is trying to remove a managed role from a member.
--> Not trying to remove a role
It is trying to execute a forbidden action on the server owner.
--> Not editing a user, but a channel (and server owwner does not have this role)
It is trying to execute an action based on another unfulfilled factor (for example reserved for partnered guilds).
--> I don't understand this one but it couldn't be that
It is trying to execute an action on a voice channel without the VIEW_CHANNEL permission.
--> Not executing an action on a voice channel, but on a Category channel, and it has VIEW_CHANNEL permission

更多信息:
1/完全相同的上下文中的相同命令适用于其他一些组,例如这个:

More information :
1/ The same command in the exact same context works with some other groups, like this one :

Role {
    id: 'XXXXXXXXX',
      name: 'Job',
      color: 0,
      hoist: false,
      rawPosition: 1,
      permissions: Permissions { bitfield: 37211712 },
      managed: false,
      mentionable: false,
      deleted: false
}

2/相同的命令适用于Administrator";分配给机器人的权限
3/当然,添加管理员";对机器人的许可不是一种选择

2/ The same command works with "Administrator" permission assigned to the bot
3/ Of course, adding "Administrator" permission to the bot is not an option

感谢您的帮助!

推荐答案

好的,感谢discord Js社区,我找到了解决方案
我忘记授予我的机器人对该特定频道的读取权限,因此该机器人无法向他无权访问的频道授予权限...

Ok then I found the solution thanks to discord Js community
I forgot to give my bot read permissions on that specific channel, so the bot couldn't give permissions to a channel he didn't have access to...

我刚刚加了

    permissionOverwrites: [
        {
            id: guild.me.roles.highest,
            allow: ['VIEW_CHANNEL', 'MANAGE_CHANNELS', 'MANAGE_ROLES']
        }
    ]

我的频道创建,它的工作原理.

to my channel creation, and it works.

这篇关于DiscordAPIError:createOverwrite 上缺少访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆