admin管理员组文章数量:1428988
I am currently writing a discord bot and i need it to create channel with specific permissions.
For example @everyone shouldn't have view_channel permission. What i have tried :
message.guild.channels.create("Channel Name", { type: "voice" })
.then((newChannel) => { newChannel.overwritePermissions(
everyone.id,
{
VIEW_CHANNEL: false
});
})
It creates the channel but permissions doesn't changing...
I am using "discord.js v12+" module.
I am currently writing a discord bot and i need it to create channel with specific permissions.
For example @everyone shouldn't have view_channel permission. What i have tried :
message.guild.channels.create("Channel Name", { type: "voice" })
.then((newChannel) => { newChannel.overwritePermissions(
everyone.id,
{
VIEW_CHANNEL: false
});
})
It creates the channel but permissions doesn't changing...
I am using "discord.js v12+" module.
-
1
Instead of creating a variable for
everyoneRole
and usingeveryoneRole.id
, you can just usemessage.guild.id
. Fun fact, the @everyone role shares the same ID as the guild its in. – Lioness100 Commented Sep 25, 2020 at 21:33
1 Answer
Reset to default 3You can pass in the permissions when creating the channel
let everyoneRole = msg.guild.roles.cache.find(r => r.name === '@everyone');
message.guild.channels.create('channel name', {
type: 'voice',
permissionOverwrites: [
{
id: everyoneRole.id,
deny: ['VIEW_CHANNEL'],
},
],
})
本文标签: javascriptJS Discord BotCreating Channel With Specific Permissions ( v12 )Stack Overflow
版权声明:本文标题:javascript - JS Discord Bot - Creating Channel With Specific Permissions ( v12+ ) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745536449a2662293.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论