Discord.js 权限覆盖创建频道不会更改权限? [英] Discord.js permissionOverwrites on creating a channel WON'T change the permissions?
问题描述
我正在 Node.js(Discord.js v12 稳定版)上编写一个 Discord.js 机器人,我希望它更改/覆盖所创建频道的权限.
I'm writing a Discord.js bot on Node.js (Discord.js v12 stable), and I want it to change/overwrite permissions of the channel which was created.
下面的代码,我试过了……
Following code, I've tried...
message.guild.channels.create('channelname', {
type: 'text',
permissionOverwrites: [{
id: message.guild.id,
deny: ['VIEW_CHANNEL'],
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL'],
},
],
});
... 似乎只是忽略了 permissionOverwrites: [ ] 部分并继续代码而没有任何错误.上面的代码实际上是 discord.js 指南网站的示例(https://discordjs.guide/popular-topics/permissions.html#adding-overwrites).我在这里有点困惑,因为它根本没有显示任何错误,而且有点忽略了 permissionOverwrites 部分.
... seemed to just ignore the permissionOverwrites: [ ] part and continue the code without any errors. The code above is actually an example of discord.js guide's website (https://discordjs.guide/popular-topics/permissions.html#adding-overwrites). I'm a little confused here, as it shows no errors at all and kinda just ignores the permissionOverwrites part.
感谢您的帮助!
推荐答案
你可以试试:
message.guild.channels.create('channelname', {
type: 'text'
}).then(channel => {
channel.overwritePermissions([
{
id: message.guild.id,
deny: ['VIEW_CHANNEL']
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL']
}]);
});
这篇关于Discord.js 权限覆盖创建频道不会更改权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!