在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));
}
答案 0 :(得分:0)
使用createOverwrite
代替permissionOverwrites
。
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));
您也可以在制作频道后设置频道,而不必在制作频道后设置父频道。