From 04e9bc26c05001913c7f20234c0301f6a2df6ae8 Mon Sep 17 00:00:00 2001
From: loicbersier <loic.bersier1@gmail.com>
Date: Thu, 19 Mar 2020 16:07:46 +0100
Subject: [PATCH] Loading message

---
 commands/utility/screenshot.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/commands/utility/screenshot.js b/commands/utility/screenshot.js
index 01696190..3ccc785f 100644
--- a/commands/utility/screenshot.js
+++ b/commands/utility/screenshot.js
@@ -35,6 +35,8 @@ class screenshotCommand extends Command {
 			.setColor(message.member.displayHexColor)
 			.setTitle(args.url);
 
+		let loadingmsg = await message.channel.send('Taking a screenshot <a:loadingmin:527579785212329984>');
+
 		// eslint-disable-next-line no-useless-escape
 		let urlregex = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/);
 		if (args.url.match(urlregex)) { // Only allow link with http/https
@@ -48,16 +50,19 @@ class screenshotCommand extends Command {
 				.catch((err) => {
 					console.error(err);
 					Embed.setDescription(err.toString());
+					loadingmsg.delete();
 					return message.channel.send(Embed);
 				})
 				.then(() => {
 					if (fs.existsSync(`${os.tmpdir()}/${message.id}.jpg`)) {
 						Embed.attachFiles([`${os.tmpdir()}/${message.id}.jpg`]);
 						Embed.setImage(`attachment://${message.id}.jpg`);
+						loadingmsg.delete();
 						return message.channel.send(Embed);
 					}
 				});
 		} else {
+			loadingmsg.delete();
 			return message.channel.send('The URL you used doesn\'t correspond to a website!');
 		}
 	}