覆盖权限未更改discord.js v12



在discord.js v12之后,我几乎通过bot更新了所有内容,但我对最后一个命令有问题,权限不适用,可能是什么问题?

if(userTickets.has(message.author.id) || message.guild.channels.cache.some(channel => channel.name.toLowerCase() === message.author.username + 's-ticket')) {
message.author.send("EN: You already have a ticket!");
} else {
let guild = message.guild;
message.guild.channels.create("📄- " + `${message.author.username}s-ticket`, {
type: 'text',
createOverwrite:[
{
id: message.author.id,
allow: 'VIEW_CHANNEL',
},
{
id: guild.id, 
deny: 'VIEW_CHANNEL',
},
{
id: '',
allow: 'VIEW_CHANNEL',
}
]
}).then(ch => {
ch.setParent('');
ch.send("=")
userTickets.set(message.author.id, ch.id);
let sChannel = message.guild.channels.cache.get("=")
sChannel.send("Created " + ch.name + " channel.")
//console.log(userTickets);
console.log(userTickets)
}).catch(err => console.log(err));
}

使用permissionOverwrites而不是createOverwrite

let guild = message.guild;
message.guild.channels.create("📄- " + `${message.author.username}s-ticket`, {
type: 'text',
permissionOverwrites:[
{
id: message.author.id,
allow: ['VIEW_CHANNEL'],
},
{
id: guild.id, 
deny: ['VIEW_CHANNEL'],
}
],
parent: '' //parent id here
}).then(ch => {
ch.send("=")
userTickets.set(message.author.id, ch.id);
}).catch(err => console.log(err));

您也可以在制作频道后不设置父频道,只需在制作频道时设置频道即可。

最新更新