discord.js将通道的权限设置为“ /”(中性)

时间:2020-09-15 10:38:04

标签: javascript node.js discord.js

我正在尝试将文本通道上的用户权限设置为中性/空/“ /”,但是overwritePermissions()目前似乎仅使用allow和deny,past post I saw显示将值设置为null,但是允许/拒绝似乎可以阻止这种情况。

我正在这样设置文本通道的权限:

member.guild.channels.cache.array().forEach((channel) => {
 channel.overwritePermissions([
  {
   id: member,
   deny: ['VIEW_CHANNEL'],
  },
 ]);
});

,并想有效地撤消此操作,将['VIEW_CHANNEL']权限更改为允许会覆盖服务器中的其他权限,因此不适用于我的情况。

overwritePermissions() documentation

1 个答案:

答案 0 :(得分:0)

我相信您正在寻找的是Channel#updateOverwrites(),它与overwritePermissions()的功能不同,但格式也不同。

overwritePermissions覆盖通道中的所有权限(如其名称所建议)。因此,即使您只想更改一件事情,overwritePermissions也会带来一切。值得庆幸的是,我们还有updateOverwrites。此方法只会更改一个成员/角色的权限。

这里是使用方式:

// as a note, `forEach()` automatically coverts the collection to an array,
// so no need for the `array()` function
member.guild.channels.cache.forEach((channel) => {
 channel.updateOverwrite(member, { // update permissions only for the member
  VIEW_CHANNEL: null, // set view_channel to default
 });
});