From 30fd908444a4827b37b90ecebe3caf3713bffa4e Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 1 Jan 2019 08:32:29 +0100 Subject: [PATCH] when people add/remove bot --- listeners/guildCreate.js | 30 ++++++++++++++++++++++++++++++ listeners/guildDelete.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 listeners/guildCreate.js create mode 100644 listeners/guildDelete.js diff --git a/listeners/guildCreate.js b/listeners/guildCreate.js new file mode 100644 index 00000000..dda1e713 --- /dev/null +++ b/listeners/guildCreate.js @@ -0,0 +1,30 @@ +const { Listener } = require('discord-akairo'); +const { statsChannel } = require('./config.json'); + + +class guildCreateListener extends Listener { + constructor() { + super('guildCreate', { + emitter: 'client', + eventName: 'guildCreate' + }); + } + + async exec(message) { + client.on("guildCreate", async guild => { + console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`); + const channel = client.channels.get(statsChannel); + const addEmbed = new Discord.RichEmbed() + .setColor("#52e80d") + .setTitle('Someone added me ! YAY :D') + .setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4') + .setThumbnail(guild.iconURL) + .setDescription(`${guild.name}\n${guild.id}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\n(${guild.owner.id})`) + .setTimestamp() + + channel.send({ embed: addEmbed }); + }) + } +} + +module.exports = guildCreateListener; \ No newline at end of file diff --git a/listeners/guildDelete.js b/listeners/guildDelete.js new file mode 100644 index 00000000..fc672e43 --- /dev/null +++ b/listeners/guildDelete.js @@ -0,0 +1,30 @@ +const { Listener } = require('discord-akairo'); +const { statsChannel } = require('./config.json'); + + +class guildCreateListener extends Listener { + constructor() { + super('guildDelete', { + emitter: 'client', + eventName: 'guildDelete' + }); + } + + async exec(message) { + console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}\n***BOT KICKED***`); + const channel = client.channels.get(statsChannel); + + const kickEmbed = new Discord.RichEmbed() + .setColor("#FF0000") + .setTitle('They kicked me out :(') + .setURL('https://www.youtube.com/watch?v=6n3pFFPSlW4') + .setThumbnail(guild.iconURL) + .setDescription(`${guild.name}\n${guild.id}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\n(${guild.owner.id})`) + .setTimestamp() + + channel.send({ embed: kickEmbed }); + console.log('***BOT KICKED***') + } +} + +module.exports = guildCreateListener; \ No newline at end of file