From 64105bbc8990235b3dc7357b195f252db82f93ad Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 18 Feb 2020 18:36:21 +0100 Subject: [PATCH] Send a message when no join/leave channel is setup --- commands/fun/fakejoin.js | 14 ++++++++++---- commands/fun/fakeleave.js | 15 +++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/commands/fun/fakejoin.js b/commands/fun/fakejoin.js index 4f8d7ddd..8c44ea02 100644 --- a/commands/fun/fakejoin.js +++ b/commands/fun/fakejoin.js @@ -1,4 +1,5 @@ const { Command } = require('discord-akairo'); +const joinChannel = require('../../models').joinChannel; class fakejoinCommand extends Command { constructor() { @@ -24,11 +25,16 @@ class fakejoinCommand extends Command { async exec(message, args) { let member; + const join = await joinChannel.findOne({where: {guildID: message.guild.id}}); - if (args.user) - member = message.guild.members.get(args.user.id); - else - member = message.guild.members.get(message.author.id); + if (join) { + if (args.user) + member = message.guild.members.get(args.user.id); + else + member = message.guild.members.get(message.author.id); + } else { + return message.channel.send('There is no join channel setup'); + } this.client.emit('guildMemberAdd', member); } diff --git a/commands/fun/fakeleave.js b/commands/fun/fakeleave.js index a5973635..39314154 100644 --- a/commands/fun/fakeleave.js +++ b/commands/fun/fakeleave.js @@ -1,4 +1,5 @@ const { Command } = require('discord-akairo'); +const leaveChannel = require('../../models').leaveChannel; class fakeleaveCommand extends Command { constructor() { @@ -24,10 +25,16 @@ class fakeleaveCommand extends Command { async exec(message, args) { let member; - if (args.user) - member = message.guild.members.get(args.user.id); - else - member = message.guild.members.get(message.author.id); + const leave = await leaveChannel.findOne({where: {guildID: message.guild.id}}); + + if (leave) { + if (args.user) + member = message.guild.members.get(args.user.id); + else + member = message.guild.members.get(message.author.id); + } else { + return message.channel.send('There is no leave channel setup'); + } this.client.emit('guildMemberRemove', member); }