我有一个机器人,该机器人具有可以为特定问题提供支持票证的功能,并且过去可以正常工作。现在它也可以正常工作,但是它只会在控制台中不断出现此错误。
(node:9252) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Channel
at RequestHandler.execute (E:\Github Repos\Baby-Bolt\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async RequestHandler.push (E:\Github Repos\Baby-Bolt\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
at async MessageManager.delete (E:\Github Repos\Baby-Bolt\node_modules\discord.js\src\managers\MessageManager.js:126:5)
(node:9252) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
答案 0 :(得分:0)
这是代码btw
const db = require('quick.db');
// Listener Event: This will run Whenever a Message is created in a Channel The Bot Has Access To View
client.on('message', async message => {
//
if(message.author.bot) return;
//
if(message.channel.type !== 'text') {
//
let active = await db.fetch(`support_${message.author.id}`);
//
let guild = client.guilds.cache.get('591704780645072898');
//Variables
let channel, found=true;
try{
if (active) client.channels.get(active.channelID).guild;
} catch (e) {
found = false;
}
if(!active || !found) {
active = {};
channel = await guild.channels.create(`${message.author.username}-${message.author.discriminator}`, {
parent: '671619413832630276',
topic: `__***^complete***__ to close the ticket`
});
let author = message.author;
const newChannel = new Discord.MessageEmbed()
.setColor(0x36393e)
.setAuthor(author.tag, author.displayAvatarURL())
.setFooter('Support Ticket Created')
.addField('User', author)
.addField('ID', author.id)
await channel.send(newChannel);
const newTicket = new Discord.MessageEmbed()
.setColor(0x36393e)
.setAuthor(`Hello, ${author.tag}`, author.displayAvatarURL())
.setFooter('Support Ticket Created')
await author.send(newTicket);
active.channelID = channel.id;
active.targetID = author.id;
}
//channel = channel.get(active.channelID);
const dm = new Discord.MessageEmbed()
.setColor(0x36393e)
.setAuthor(message.author.tag, message.author.displayAvatarURL())
.setDescription(message.content)
.setFooter(`Message Recieved -- ${message.author.tag}`)
await channel.send(dm);
db.set(`support_${message.author.id}`, active);
db.set(`supportChannel_${channel.id}`, message.author.id);
return;
}
let support = await db.fetch(`supportChannel_${message.channel.id}`);
if(support) {
support = await db.fetch(`support_${support}`);
let supportUser = client.users.cache.get(support.targetID);
if (!supportUser) return message.channel.delete();
if (message.content.toLowerCase() === '^complete') {
const complete = new Discord.MessageEmbed()
.setColor(0x36393e)
.setAuthor(`Hey, ${supportUser.tag}`, supportUser.displayAvatarURL())
.setFooter('Ticket Closed -- Bismillah Biryani')
.setDescription('*Your ticket has been marked as ***complete***. If You Wish To Reopen This, Or Create A New One, Please Send A Message To The Bot')
supportUser.send(complete);
message.channel.delete();
db.delete(`support_${support.targetID}`);
}
const embed = new Discord.MessageEmbed()
.setColor(0x36393e)
.setAuthor(message.author.tag, message.author.displayAvatarURL())
.setFooter(`Message Recieved --- Bismillah Biryani`)
.setDescription(message.content)
client.users.cache.get(support.targetID).send(embed)
message.delete({timeout: 1000});
embed.setFooter(`Message Sent -- ${supportUser.tag}`).setDescription(message.content);
return message.channel.send(embed);
}
});