From 72325aa98a15ab654260b8181140f955e145b02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Thu, 9 May 2019 21:29:24 +0200 Subject: [PATCH] welcome message --- commands/admin/welcome.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 commands/admin/welcome.js diff --git a/commands/admin/welcome.js b/commands/admin/welcome.js new file mode 100644 index 00000000..cf04beb3 --- /dev/null +++ b/commands/admin/welcome.js @@ -0,0 +1,39 @@ +const { Command } = require('discord-akairo'); +const fs = require('fs'); + +class welcomeCommand extends Command { + constructor() { + super('welcome', { + aliases: ['welcome'], + category: 'admin', + channelRestriction: 'guild', + userPermissions: ['MANAGE_CHANNELS'], + args: [ + { + id: 'message', + type: 'string', + match: 'rest' + } + ], + description: { + content: 'Set welcome message when user join, can use [member] to get the name of the user joining and [server] to get the name of the server', + usage: '[welcome message]', + examples: ['everyone welcome [adjectives] [member] and welcome on [server]'] + } + }); + } + + async exec(message, args) { + let welcomeChannel = message.channel.id; + + fs.writeFile(`./welcome/${message.guild.id}.json`, `{"channel": "${welcomeChannel}", "message": "${args.message}"}`, function (err) { + if (err) { + console.log(err); + } + }); + + return message.channel.send(`This channel will now be used to welcome new user with the following message: ${args.message}`); + } +} + +module.exports = welcomeCommand; \ No newline at end of file