mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 21:40:49 +02:00
Make Cleverbot accept a single response
This commit is contained in:
@@ -303,15 +303,15 @@ client.on('messageCreate', async msg => {
|
|||||||
msg.channel.sendTyping().catch(() => null);
|
msg.channel.sendTyping().catch(() => null);
|
||||||
try {
|
try {
|
||||||
const response = await cleverbot.respond(msg.cleanContent);
|
const response = await cleverbot.respond(msg.cleanContent);
|
||||||
await msg.channel.send(response);
|
await msg.reply(response);
|
||||||
return;
|
return;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.status === 503) {
|
if (err.status === 503) {
|
||||||
await msg.channel.send('Monthly API limit reached. Ending conversation.');
|
await msg.reply('Monthly API limit reached. Ending conversation.');
|
||||||
client.cleverbots.delete(msg.channel.id);
|
client.cleverbots.delete(msg.channel.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await msg.channel.send('Sorry, blacked out there for a second. Come again?');
|
await msg.reply('Sorry, blacked out there for a second. Come again?');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,15 +17,34 @@ module.exports = class CleverbotCommand extends Command {
|
|||||||
reason: 'API',
|
reason: 'API',
|
||||||
reasonURL: 'https://www.cleverbot.com/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)) {
|
if (this.client.cleverbots.has(msg.channel.id)) {
|
||||||
return msg.say('There is already a Cleverbot conversation in this channel.');
|
return msg.say('There is already a Cleverbot conversation in this channel.');
|
||||||
}
|
}
|
||||||
const cleverbot = new Cleverbot(this.client, msg.channel.id, msg.author.id);
|
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);
|
this.client.cleverbots.set(msg.channel.id, cleverbot);
|
||||||
const usage = this.client.registry.commands.get('cleverbot-end').usage();
|
const usage = this.client.registry.commands.get('cleverbot-end').usage();
|
||||||
return msg.reply(stripIndents`
|
return msg.reply(stripIndents`
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "151.1.0",
|
"version": "151.2.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user