Fix bug in portal, cleverbot group

This commit is contained in:
Dragon Fire
2021-04-18 08:33:03 -04:00
parent c6996cccdf
commit 09924d6973
5 changed files with 16 additions and 14 deletions
+21
View File
@@ -0,0 +1,21 @@
const Command = require('../../structures/Command');
module.exports = class CleverbotEndCommand extends Command {
constructor(client) {
super(client, {
name: 'cleverbot-end',
aliases: ['clevs-end', 'chat-end'],
group: 'cleverbot',
memberName: 'cleverbot-end',
description: 'Ends the current Cleverbot chat.'
});
}
run(msg) {
const cleverbot = this.client.cleverbots.get(msg.channel.id);
if (!cleverbot) return msg.say('There is not a Cleverbot conversation in this channel.');
clearTimeout(cleverbot.timeout);
this.client.cleverbots.delete(msg.channel.id);
return msg.reply(`Ended the current conversation. Chatted **${cleverbot.interactions}** times.`);
}
};
+36
View File
@@ -0,0 +1,36 @@
const Command = require('../../structures/Command');
const { stripIndents } = require('common-tags');
const Cleverbot = require('../../structures/Cleverbot');
module.exports = class CleverbotCommand extends Command {
constructor(client) {
super(client, {
name: 'cleverbot',
aliases: ['clevs', 'chat'],
group: 'cleverbot',
memberName: 'cleverbot',
description: 'Starts a Cleverbot conversation.',
credit: [
{
name: 'Cleverbot',
url: 'https://www.cleverbot.com/',
reason: 'API',
reasonURL: 'https://www.cleverbot.com/api/'
}
]
});
}
run(msg) {
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);
this.client.cleverbots.set(msg.channel.id, cleverbot);
const usage = this.client.registry.commands.get('cleverbot-end').usage();
return msg.reply(stripIndents`
Cleverbot is now active in this channel, replying to ${msg.author}.
To end the conversation, use ${usage}.
`);
}
};