From b8c8ea94228277c2cf1b3a86ba2ff48a1243b379 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 7 Mar 2021 20:39:27 -0500 Subject: [PATCH] Show final interaction count --- Xiao.js | 2 ++ commands/other/cleverbot-end.js | 7 +++---- package.json | 2 +- structures/Cleverbot.js | 2 ++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Xiao.js b/Xiao.js index ccb6d210..32ba4daf 100644 --- a/Xiao.js +++ b/Xiao.js @@ -161,7 +161,9 @@ client.on('message', async msg => { const cleverbot = client.cleverbots.get(msg.channel.id); if (cleverbot) { if (!cleverbot.shouldRespond(msg)) return; + msg.channel.startTyping().catch(() => null); const response = await cleverbot.respond(msg.cleanContent); + msg.channel.stopTyping(true); await msg.channel.send(response); return; } diff --git a/commands/other/cleverbot-end.js b/commands/other/cleverbot-end.js index d28ef4d6..5b45c23d 100644 --- a/commands/other/cleverbot-end.js +++ b/commands/other/cleverbot-end.js @@ -12,10 +12,9 @@ module.exports = class CleverbotEndCommand extends Command { } run(msg) { - if (!this.client.cleverbots.has(msg.channel.id)) { - return msg.say('There is not a Cleverbot conversation in this channel.'); - } + const cleverbot = this.client.cleverbots.get(msg.channel.id); + if (!cleverbot) return msg.say('There is not a Cleverbot conversation in this channel.'); this.client.cleverbots.delete(msg.channel.id); - return msg.reply('Ended the current conversation.'); + return msg.reply(`Ended the current conversation. Chatted **${cleverbot.interactions}** times.`); } }; diff --git a/package.json b/package.json index 6d9bbe31..a042aa10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "131.11.0", + "version": "131.11.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/Cleverbot.js b/structures/Cleverbot.js index 2321b695..97ea3f35 100644 --- a/structures/Cleverbot.js +++ b/structures/Cleverbot.js @@ -9,6 +9,7 @@ module.exports = class Cleverbot { this.channelID = channelID; this.authorID = authorID; this.cs = null; + this.interactions = 0; this.timeout = this.setTimeout(); this.key = key; } @@ -29,6 +30,7 @@ module.exports = class Cleverbot { clearTimeout(this.timeout); this.timeout = this.setTimeout(); this.cs = body.cs; + this.interactions = Number.parseInt(body.interaction_count, 10); return body.output || blankResponses[Math.floor(Math.random() * blankResponses.length)]; }