我有一些代码可以根据发布请求创建一个新频道。一切正常,除非我将创建放入 if 语句以检查票证是否已存在。这是我的代码
const guild = await client.guilds.fetch('858917141063401512');
const user = await client.users.cache.get(content.id);
const prefix = 't!';
if (client.channels.cache.find(channel => channel.name === `ticket-${content.id}`)) {
user.send('you already have a ticket, please close your exsisting ticket first before opening a new one!');
created = true;
} else {
created = false;
guild.channels.create(`ticket-${content.id}`, {
permissionOverwrites: [
{
id: content.id,
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
},
{
id: '858917141063401512', //change to everyone ID in server
deny: ['VIEW_CHANNEL'],
},
],
type: 'text',
}).then(async channel => {
user.send(`you have successfully created a ticket! Please click on ${channel} to view your ticket.`);
user.send(`Hi ${content.id}, welcome to your ticket! Please be patient, we will be with you shortly. If you would like to close this ticket please run \`${prefix}close\``);
let logchannel = guild.channels.cache.find(channel => channel.name === `ticket-logs`);
if (logchannel) {
logchannel.send(`Ticket ${content.id} created. Click the following to view <#${channel.id}>`);
}
});
}
我收到的错误是
(node:1793) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.
对于线
guild.channels.create(`ticket-${content.id}`, {