如何创建仅给定角色可以看到的渠道?

时间:2020-05-25 11:00:53

标签: discord.js

struct list *tp = ll;
while(tp)
{
    printf("\n%d",tp->data);
    tp=tp->link;
}

我只希望该角色可以看到此频道

msg.guild.createRole({ name: msg.author.username, color: "#ff0000" }).then(role => { msg.member.addRole(role) })

guild.createChannel( `${msg.author.username}`, "text")
    .then(channel => {
    let category = guild.channels.find(c => c.name == "INFO" && c.type == "category");

有可能吗?

1 个答案:

答案 0 :(得分:1)

可以创建仅给定角色可以看到的频道。它称为 Overwrite Permission
要在频道中添加新权限,请使用

<Text Channel>.overwritePermission(<Role>,
      {
       VIEW_CHANNEL: true,
       SEND_MESSAGES: true /* you can remove send messages part if need */ 
      }
    )

<Text Channel>替换为定义的文本通道,将<Role>替换为定义为您的代码的角色

msg.guild.createRole({
    name: msg.author.username, 
    color: "#ff0000"
}).then(role => {
    msg.member.addRole(role)
    guild.createChannel( `${msg.author.username}`, "text")
    .then(channel => { 
        channel.overwritePermission(role, {
             VIEW_CHANNEL: true,
             SEND_MESSAGES: true
        })
    }) 
})

您还可以通过按here

阅读有关该文档的信息