Discord.js 如何创建只有给定角色才能看到的频道?

Discord.js 如何创建只有给定角色才能看到的频道?,discord.js,Discord.js,我想只有这个角色才能看到这个频道 guild.createChannel(`${msg.author.username}`,“text”) 。然后(频道=>{ 让category=guild.channels.find(c=>c.name==“INFO”&&c.type==“category”); 有可能吗?有可能创建一个只有给定角色才能看到的频道。它被称为 要在频道中添加新权限,请如下使用 。覆盖权限(, { 查看频道:正确, SEND_MESSAGES:true/*如果需要,您可以删除SEN

我想只有这个角色才能看到这个频道

guild.createChannel(`${msg.author.username}`,“text”)
。然后(频道=>{
让category=guild.channels.find(c=>c.name==“INFO”&&c.type==“category”);


有可能吗?

有可能创建一个只有给定角色才能看到的频道。它被称为
要在频道中添加新权限,请如下使用

。覆盖权限(,
{
查看频道:正确,
SEND_MESSAGES:true/*如果需要,您可以删除SEND MESSAGES部分*/
}
)
替换为定义的文本频道,
替换为定义为代码的角色,如下所示

msg.guild.createRole({
名称:msg.author.username,
颜色:“ff0000”
})。然后(角色=>{
msg.member.addRole(角色)
guild.createChannel(`${msg.author.username}`,“文本”)
.然后(通道=>{
频道覆盖权限(角色{
查看频道:正确,
发送消息:true
})
}) 
})

您还可以按

阅读相关文档。这是一个很好的答案。感谢您不仅提供了正确的代码,还提供了所需内容和更改内容的说明以及参考资料。
 msg.guild.createRole({
    name: msg.author.username, 
    color: "#ff0000"
  }).then(role => {
    msg.member.addRole(role)
  })
if (!category) throw new Error("Category channel does not exist");
 channel.setParent(category.id).then(
 channel.send(embed)