Haha-Yes/event/listeners/guildCreate.js

42 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-01-01 08:32:29 +01:00
const { Listener } = require('discord-akairo');
2019-01-10 09:00:30 +01:00
const { statsChannel } = require('../../config.json');
2020-04-30 03:13:46 +02:00
const guildBlacklist = require('../../models').guildBlacklist;
2019-01-01 08:32:29 +01:00
class guildCreateListener extends Listener {
2019-01-02 08:09:45 +01:00
constructor() {
super('guildCreate', {
emitter: 'client',
2019-01-02 21:46:12 +01:00
event: 'guildCreate'
2019-01-02 08:09:45 +01:00
});
}
2019-01-01 08:32:29 +01:00
2019-01-02 08:09:45 +01:00
async exec(guild) {
await guild.members.fetch();
2019-01-02 08:09:45 +01:00
console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`);
const channel = this.client.channels.resolve(statsChannel);
2020-03-07 13:42:47 +01:00
let botCount = guild.members.cache.filter(member => member.user.bot).size;
2019-11-22 12:30:20 +01:00
const addEmbed = this.client.util.embed()
2019-01-02 08:09:45 +01:00
.setColor('#52e80d')
.setTitle('New boiz in town')
2019-01-02 08:09:45 +01:00
.setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4')
.setThumbnail(guild.iconURL())
.addField('Guild', `${guild.name} (${guild.id})`)
2019-11-07 15:29:58 +01:00
.addField('Total number of members', guild.memberCount, true)
2020-03-07 13:42:47 +01:00
.addField('Number of users', guild.memberCount - botCount, true)
.addField('Number of bots', botCount, true)
.addField('Owner', `${guild.owner.user.username} (${guild.owner.id})`, true)
.setFooter(`I'm now in ${this.client.guilds.cache.size} servers!`)
2019-01-02 08:09:45 +01:00
.setTimestamp();
2020-04-15 17:15:20 +02:00
2020-04-30 03:13:46 +02:00
const blacklist = await guildBlacklist.findOne({where: {guildID:guild.id}});
2020-04-15 17:15:20 +02:00
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})`);
}
2019-01-02 08:09:45 +01:00
channel.send({ embed: addEmbed });
}
2019-01-01 08:32:29 +01:00
}
module.exports = guildCreateListener;