added --remove and default messages

merge-requests/4/head
loicbersier 5 years ago
parent 5ca6515616
commit 8441ad09df

@ -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!');
}
});

@ -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;

@ -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;

@ -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!');
}
});

Loading…
Cancel
Save