From 73da34c8578a8921b3e8c1a83e962dc5076ee26e Mon Sep 17 00:00:00 2001 From: loicbersier Date: Wed, 15 Apr 2020 17:15:20 +0200 Subject: [PATCH] leave guild if owner is blacklisted --- event/listeners/guildCreate.js | 10 +++++++++- event/listeners/guildDelete.js | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/event/listeners/guildCreate.js b/event/listeners/guildCreate.js index ae4b4a6c..5cd44b91 100644 --- a/event/listeners/guildCreate.js +++ b/event/listeners/guildCreate.js @@ -1,5 +1,6 @@ const { Listener } = require('discord-akairo'); const { statsChannel } = require('../../config.json'); +const userBlacklist = require('../../models').userBlacklist; class guildCreateListener extends Listener { @@ -28,7 +29,14 @@ class guildCreateListener extends Listener { .addField('Owner ID', guild.owner.id, true) .setFooter(`I'm now in ${this.client.guilds.cache.size} servers!`) .setTimestamp(); - + + const blacklist = await userBlacklist.findOne({where: {userID:guild.owner.id}}); + + if (blacklist) { + guild.leave(); + return channel.send(`${guild.owner.user.username} (${guild.owner.id}) tried to add me to their guild while being blacklisted!\n${guild.name} (${guild.id})`); + } + channel.send({ embed: addEmbed }); } } diff --git a/event/listeners/guildDelete.js b/event/listeners/guildDelete.js index 3ce18bcb..46ad26cb 100644 --- a/event/listeners/guildDelete.js +++ b/event/listeners/guildDelete.js @@ -1,5 +1,6 @@ const { Listener } = require('discord-akairo'); const { statsChannel } = require('../../config.json'); +const userBlacklist = require('../../models').userBlacklist; class guildCreateListener extends Listener { @@ -31,6 +32,13 @@ class guildCreateListener extends Listener { .setFooter(`I'm now in ${this.client.guilds.cache.size} servers!`) .setTimestamp(); + const blacklist = await userBlacklist.findOne({where: {userID:guild.owner.id}}); + + if (blacklist) { + guild.leave(); + kickEmbed.setFooter(kickEmbed.footer + ' | Left this guild because owner is blacklisted!'); + } + channel.send({ embed: kickEmbed }); } }