admin管理员组文章数量:1293335
I would like to add some members to the specific channel in Guild so only they are able to see the channel. I am creating a new channel via this script
const channel = await guild.channels.create({
parent: category.id,
name: 'test-room',
type: ChannelType.GuildText,
});
I would also like to add some specific role to this channel so each member of the role can see the channel
More clarification: imagine you have a channel for each member joined to the discord. Something like a support channel. Each one member has its own channel that only he and the support team can see. So I need to create a channel and add permissions for the support team and for the given user to be able to see and write to that channel
I would like to add some members to the specific channel in Guild so only they are able to see the channel. I am creating a new channel via this script
const channel = await guild.channels.create({
parent: category.id,
name: 'test-room',
type: ChannelType.GuildText,
});
I would also like to add some specific role to this channel so each member of the role can see the channel
More clarification: imagine you have a channel for each member joined to the discord. Something like a support channel. Each one member has its own channel that only he and the support team can see. So I need to create a channel and add permissions for the support team and for the given user to be able to see and write to that channel
Share edited Feb 17 at 7:45 Kuba Šimonovský asked Feb 12 at 17:48 Kuba ŠimonovskýKuba Šimonovský 2,0412 gold badges18 silver badges37 bronze badges 4- what problem are you encountering? – G-Force Commented Feb 12 at 20:46
- If I create a channel, everyone can see that channel. I need to set specific users who can see the channel – Kuba Šimonovský Commented Feb 17 at 7:46
- so create a channel. create a role. assign permissions to the channel with what role(s) you want, with what permission(s) for each role(s). Then assign users to that role, and you have what you want. – G-Force Commented Feb 17 at 16:53
- yeah and thats exactly what I asked.. how to programatically assign permissions to the channel.. – Kuba Šimonovský Commented Feb 22 at 16:15
1 Answer
Reset to default 1You can add permission overwrites to the channel:
const channel = await guild.channels.create({
parent: category.id,
name: 'test-room',
type: ChannelType.GuildText,
permissionOverwrites: [
{ // disallow everyone to see the channel
id: guild.id,
deny: [PermissionsBitField.Flags.ViewChannel],
},
{ // allow the user to see the channel
id: theUser.id,
allow: [PermissionsBitField.Flags.ViewChannel],
},
{ // allow the user to see the channel
id: supportTeamRole.id,
allow: [PermissionsBitField.Flags.ViewChannel],
},
],
});
Then only the user and the admin can see this channel.
Further Information: Adding overwrites
本文标签: discordjs v14 add member to a channelStack Overflow
版权声明:本文标题:discord.js v14 add member to a channel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741578002a2386402.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论