diff --git a/commands/admin/bye.js b/commands/admin/bye.js index 5dd409f..ea72b0b 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 95ea4c0..0000000 --- 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 e84539c..0000000 --- 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 46460b1..7ecfd8e 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!'); } });