mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-23 18:05:01 +02:00
Handle Cleverbot errors.
This commit is contained in:
@@ -162,10 +162,21 @@ client.on('message', async msg => {
|
|||||||
if (cleverbot) {
|
if (cleverbot) {
|
||||||
if (!cleverbot.shouldRespond(msg)) return;
|
if (!cleverbot.shouldRespond(msg)) return;
|
||||||
msg.channel.startTyping().catch(() => null);
|
msg.channel.startTyping().catch(() => null);
|
||||||
const response = await cleverbot.respond(msg.cleanContent);
|
try {
|
||||||
msg.channel.stopTyping(true);
|
const response = await cleverbot.respond(msg.cleanContent);
|
||||||
await msg.channel.send(response);
|
msg.channel.stopTyping(true);
|
||||||
return;
|
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
|
// Phone message handler
|
||||||
|
|||||||
Reference in New Issue
Block a user