mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-12 15:57:43 +02:00
Make Cleverbot accept a single response
This commit is contained in:
@@ -17,15 +17,34 @@ module.exports = class CleverbotCommand extends Command {
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.cleverbot.com/api/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
async run(msg, { text }) {
|
||||
if (this.client.cleverbots.has(msg.channel.id)) {
|
||||
return msg.say('There is already a Cleverbot conversation in this channel.');
|
||||
}
|
||||
const cleverbot = new Cleverbot(this.client, msg.channel.id, msg.author.id);
|
||||
if (text) {
|
||||
msg.channel.sendTyping().catch(() => null);
|
||||
try {
|
||||
const response = await cleverbot.respond(text);
|
||||
return msg.reply(response);
|
||||
} catch (err) {
|
||||
if (err.status === 503) {
|
||||
return msg.reply('Monthly API limit reached. Ending conversation.');
|
||||
}
|
||||
return msg.reply('Sorry, blacked out there for a second. Come again?');
|
||||
}
|
||||
}
|
||||
this.client.cleverbots.set(msg.channel.id, cleverbot);
|
||||
const usage = this.client.registry.commands.get('cleverbot-end').usage();
|
||||
return msg.reply(stripIndents`
|
||||
|
||||
Reference in New Issue
Block a user