需要更新特定角色的覆盖权限[Discord.js V12]

时间:2020-07-02 21:02:26

标签: discord.js

如何更新特定角色的覆盖?我希望@Player在触发命令时在特定的频道中交谈,我不知道if (ballposY < 0) { ballYdir = -ballYdir; } 的工作方式是在使用Discord.js V12

1 个答案:

答案 0 :(得分:1)

首先overwritePermissions,就像它说覆盖所有权限一样,您可能需要updateOverwrites

两者都需要可解析的角色或用户可解析的角色,因此第一步是获取该角色:

const guild = <Guild>;
const role = guild.roles.cache.get(role_id);
const role2 = guild.roles.cache.find(role => role.name === "Player");

获得该角色后,您需要一个频道来更改以下权限:

const guild = <Guild>;
const message = <Message>;
const channel = message.chanenl;
const channel2 = guild.channels.cache.get(channel_id);
const channel3 = guild.channels.cache.find(channel => channel.name === "name-here");

之后,您可以使用以下方法:

channel.updateOverwrite(role, { VIEW_MESSAGES: true, SEND_MESSAGES: true });

channel.overwritePermissions([
  {
    id: role.id,
    allow: ["VIEW_MESSAGES", "SEND_MESSAGES"]
  }
]);