From 8441ad09df76da4832ebc5b29be557397f21f9b6 Mon Sep 17 00:00:00 2001
From: loicbersier <loic.bersier1@gmail.com>
Date: Sat, 9 Nov 2019 12:02:55 +0100
Subject: [PATCH] added --remove and default messages

---
 commands/admin/bye.js       | 28 ++++++++++++++++++++++------
 commands/admin/unbye.js     | 31 -------------------------------
 commands/admin/unwelcome.js | 31 -------------------------------
 commands/admin/welcome.js   | 23 +++++++++++++++++++----
 4 files changed, 41 insertions(+), 72 deletions(-)
 delete mode 100644 commands/admin/unbye.js
 delete mode 100644 commands/admin/unwelcome.js

diff --git a/commands/admin/bye.js b/commands/admin/bye.js
index 5dd409f3..ea72b0b8 100644
--- a/commands/admin/bye.js
+++ b/commands/admin/bye.js
@@ -4,24 +4,28 @@ const fs = require('fs');
 class byeCommand extends Command {
 	constructor() {
 		super('bye', {
-			aliases: ['bye'],
+			aliases: ['bye', 'leave'],
 			category: 'admin',
 			channelRestriction: 'guild',
 			userPermissions: ['MANAGE_CHANNELS'],
+			clientPermissions: ['SEND_MESSAGES'],
 			args: [
+				{
+					id: 'remove',
+					match: 'flag',
+					flag: '--remove'
+				},
 				{
 					id: 'message',
 					type: 'string',
-					prompt: {
-						start: 'What message should the bot say when a user leave?',
-					},
-					match: 'rest'
+					match: 'rest',
+					default: '[member] just left the server :('
 				}
 			],
 			description: {
 				content: 'Send a message to the current channel when a person leave, you can use [member] to show the member username and [server] to show the name of the server',
 				usage: '[bye message]',
-				examples: ['[member] leaved the server, he deserve a ban']
+				examples: ['[member] left the server, he deserve a ban']
 			}
 		});
 	}
@@ -29,9 +33,21 @@ class byeCommand extends Command {
 	async exec(message, args) {
 		let byeChannel = message.channel.id;
 
+		if (args.remove) {
+			fs.unlink(`./welcome/${message.guild.id}.json`, (err) => {
+				if (err) {
+					console.error(err);
+					return message.channel.send('An error has occured, there is most likely no welcome message set!');
+				} else {
+					return message.channel.send('Disabled unwelcome message');
+				}
+			});
+		}
+
 		fs.writeFile(`./bye/${message.guild.id}.json`, `{"channel": "${byeChannel}", "message": "${args.message}"}`, function (err) {
 			if (err) {
 				console.log(err);
+				return message.channel.send('An error has occured! im gonna be honest with you, i do not know what happened yet! but fear not! i will look into it!');
 			}
 		});
 		
diff --git a/commands/admin/unbye.js b/commands/admin/unbye.js
deleted file mode 100644
index 95ea4c0e..00000000
--- a/commands/admin/unbye.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const { Command } = require('discord-akairo');
-const fs = require('fs');
-
-class unbyeCommand extends Command {
-	constructor() {
-		super('unbye', {
-			aliases: ['unbye'],
-			category: 'admin',
-			channelRestriction: 'guild',
-			userPermissions: ['MANAGE_CHANNELS'],
-			description: {
-				content: 'Delete leaving message',
-				usage: '[]',
-				examples: ['']
-			}
-		});
-	}
-
-	async exec(message) {
-		fs.unlink(`./bye/${message.guild.id}.json`, (err) => {
-			if (err) {
-				console.error(err);
-				return message.channel.send('An error has occured, there is most likely no bye/leave message set!');
-			} else {
-				return message.channel.send('Disabled bye/leave message');
-			}
-		});
-	}
-}
-
-module.exports = unbyeCommand;
\ No newline at end of file
diff --git a/commands/admin/unwelcome.js b/commands/admin/unwelcome.js
deleted file mode 100644
index e84539c0..00000000
--- a/commands/admin/unwelcome.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const { Command } = require('discord-akairo');
-const fs = require('fs');
-
-class unwelcomeCommand extends Command {
-	constructor() {
-		super('unwelcome', {
-			aliases: ['unwelcome'],
-			category: 'admin',
-			channelRestriction: 'guild',
-			userPermissions: ['MANAGE_CHANNELS'],
-			description: {
-				content: 'Delete welcome message',
-				usage: '[]',
-				examples: ['']
-			}
-		});
-	}
-
-	async exec(message) {
-		fs.unlink(`./welcome/${message.guild.id}.json`, (err) => {
-			if (err) {
-				console.error(err);
-				return message.channel.send('An error has occured, there is most likely no welcome message set!');
-			} else {
-				return message.channel.send('Disabled unwelcome message');
-			}
-		});
-	}
-}
-
-module.exports = unwelcomeCommand;
\ No newline at end of file
diff --git a/commands/admin/welcome.js b/commands/admin/welcome.js
index 46460b17..7ecfd8e4 100644
--- a/commands/admin/welcome.js
+++ b/commands/admin/welcome.js
@@ -4,18 +4,21 @@ const fs = require('fs');
 class welcomeCommand extends Command {
 	constructor() {
 		super('welcome', {
-			aliases: ['welcome'],
+			aliases: ['welcome', 'join'],
 			category: 'admin',
 			channelRestriction: 'guild',
 			userPermissions: ['MANAGE_CHANNELS'],
 			args: [
+				{
+					id: 'remove',
+					match: 'flag',
+					flag: '--remove'
+				},
 				{
 					id: 'message',
 					type: 'string',
 					match: 'rest',
-					prompt: {
-						start: 'What message do you want to welcome peoples?',
-					}
+					default: 'Welcome [member] to [server]!'
 				}
 			],
 			description: {
@@ -29,9 +32,21 @@ class welcomeCommand extends Command {
 	async exec(message, args) {
 		let welcomeChannel = message.channel.id;
 
+		if (args.remove) {
+			fs.unlink(`./welcome/${message.guild.id}.json`, (err) => {
+				if (err) {
+					console.error(err);
+					return message.channel.send('An error has occured, there is most likely no welcome message set!');
+				} else {
+					return message.channel.send('Disabled unwelcome message');
+				}
+			});
+		}
+
 		fs.writeFile(`./welcome/${message.guild.id}.json`, `{"channel": "${welcomeChannel}", "message": "${args.message}"}`, function (err) {
 			if (err) {
 				console.log(err);
+				return message.channel.send('An error has occured! im gonna be honest with you, i do not know what happened yet! but fear not! i will look into it!');
 			}
 		});