简体   繁体   中英

Sending error in a specific channel Discord.js

I have a try...catch system to send an error to a channel when there is an error.

Here is the code:

try {
 cmd.execute(client, message, args, prefix, result);
} catch (err) {
 echannel.send(err);
}

echannel is the channel that I got with client.channels.cache.get() . The channel is the correct one.

I made a command to throw the error with:

message.channel.send('Throwing error...');
throw new Error('Testing');

I can see the error in the console though. Any help?

尝试简单地将错误发送到通道:

message.channel.send(err);

I've figured it out. I need to add process.on('uncaughtException, err => {})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM