diff --git a/Xiao.js b/Xiao.js index b8579586..a9b0df86 100644 --- a/Xiao.js +++ b/Xiao.js @@ -157,7 +157,7 @@ client.on('message', async msg => { // Cleverbot handler const cleverbot = client.cleverbots.get(msg.channel.id); - if (cleverbot) { + if (cleverbot && cleverbot.active) { if (!hasText) return; if (!cleverbot.shouldRespond(msg)) return; const response = await cleverbot.respond(msg.cleanContent); diff --git a/commands/other/cleverbot.js b/commands/other/cleverbot.js index 65c2dcd6..74d88a36 100644 --- a/commands/other/cleverbot.js +++ b/commands/other/cleverbot.js @@ -21,16 +21,18 @@ module.exports = class CleverbotCommand extends Command { }); } - run(msg) { + async 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` + await msg.reply(stripIndents` Cleverbot is now active in this channel, replying to ${msg.author}. To end the conversation, use ${usage}. `); + cleverbot.active = true; + return null; } }; diff --git a/structures/Cleverbot.js b/structures/Cleverbot.js index 0f74c8ba..09cb776a 100644 --- a/structures/Cleverbot.js +++ b/structures/Cleverbot.js @@ -11,6 +11,7 @@ module.exports = class Cleverbot { this.cs = null; this.timeout = this.setTimeout(); this.key = key; + this.active = false; } async respond(input) {