【问题标题】:How to remove role to access channel with discord.js?如何删除角色以使用 discord.js 访问频道?
【发布时间】:2021-06-07 06:45:30
【问题描述】:

我想避免会员看到特定频道。
我试过了,但我不明白为什么它不起作用。

我正在使用 discord.js v12 模块。

      const memberRole = await msg.guild.roles.cache.find((role: any) => role.name === "member")
      const permissionOverwrites = [{id: memberRole.id, deny: ['VIEW_CHANNEL']}];
      const channel = await msg.guild.channels.create(`channel`, { 
        type: "text", 
        permissionOverwrites,
        reason : "test",
      });

如果我可以从这个频道中删除整个角色,那将是完美的。

谢谢

【问题讨论】:

  • 你有什么错误吗?

标签: discord.js


【解决方案1】:

您将 v11 代码与 v12 模块一起使用。在您的情况下,您需要:

let permissionOverwriteArray = [{id: memberRole.id, deny: ['VIEW_CHANNEL']}]


guild.channels.create('new-channel', { type: 'text', permissionOverwrites: permissionOverwriteArray, reason: 'New channel!' });

【讨论】:

  • 您好,除了您将权限放入对象 permissionOverwriteArray 之外,我看不出与我的代码有什么区别?!
  • 我更新了我的帖子,但它仍然不起作用
  • 我没有错误,一切正常,但创建后我可以在频道中看到会员,我仍然有同样的问题,我不明白为什么
  • 如果你控制台登录memberRole,它会输出什么?
  • 好的,我刚刚知道了,这是因为频道在一个类别中并且它继承了该类别!谢谢
猜你喜欢
  • 1970-01-01
  • 2021-10-08
  • 2021-07-31
  • 2020-08-24
  • 2019-09-05
  • 2020-10-15
  • 1970-01-01
  • 1970-01-01
  • 2020-09-19
相关资源
最近更新 更多