mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-04 15:56:52 +02:00
Handle Cleverbot errors.
This commit is contained in:
@@ -162,10 +162,21 @@ client.on('message', async msg => {
|
||||
if (cleverbot) {
|
||||
if (!cleverbot.shouldRespond(msg)) return;
|
||||
msg.channel.startTyping().catch(() => null);
|
||||
const response = await cleverbot.respond(msg.cleanContent);
|
||||
msg.channel.stopTyping(true);
|
||||
await msg.channel.send(response);
|
||||
return;
|
||||
try {
|
||||
const response = await cleverbot.respond(msg.cleanContent);
|
||||
msg.channel.stopTyping(true);
|
||||
await msg.channel.send(response);
|
||||
return;
|
||||
} catch (err) {
|
||||
msg.channel.stopTyping(true);
|
||||
if (err.status === 503) {
|
||||
await msg.channel.send('Monthly API limit reached. Ending conversation.');
|
||||
client.cleverbots.delete(msg.channel.id);
|
||||
return;
|
||||
}
|
||||
await msg.channel.send('Sorry, blacked out there for a second. Come again?');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Phone message handler
|
||||
|
||||
Reference in New Issue
Block a user