From c754195abbe7e019d0d2b84556ea8b98956bf3c5 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 16 Jul 2020 09:22:39 +0200 Subject: [PATCH] Delete loading message after message has been sent --- commands/fun/cleverbot.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/commands/fun/cleverbot.js b/commands/fun/cleverbot.js index 4a4b251f..fdd1878c 100644 --- a/commands/fun/cleverbot.js +++ b/commands/fun/cleverbot.js @@ -30,22 +30,26 @@ class CleverBotCommand extends Command { let loadingmsg = await message.channel.send('Processing! '); if (!conversation[message.guild.id]) conversation[message.guild.id] = []; - if (!conversation[0]) { cleverbot(args.message).then(response => { conversation[message.guild.id].push(args.message); conversation[message.guild.id].push(response); - return message.channel.send(response); + return message.channel.send(response) + .then(() => { + loadingmsg.delete(); + }); }); } else { cleverbot(args.message, conversation[message.guild.id]).then(response => { conversation[message.guild.id].push(args.message); conversation[message.guild.id].push(response); - return message.channel.send(response); + return message.channel.send(response) + .then(() => { + loadingmsg.delete(); + }); }); } console.log(conversation); - loadingmsg.delete(); } } module.exports = CleverBotCommand; \ No newline at end of file