From 9cc951ea2d0c245a6bd6c02941697d3d80b46aa7 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 12 Jan 2022 02:06:15 -0500 Subject: add better guild join and leave logging --- src/listeners/guild/guildCreate.ts | 15 +++++++++++++++ src/listeners/guild/guildDelete.ts | 19 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'src/listeners/guild') diff --git a/src/listeners/guild/guildCreate.ts b/src/listeners/guild/guildCreate.ts index 16b0862..418df3a 100644 --- a/src/listeners/guild/guildCreate.ts +++ b/src/listeners/guild/guildCreate.ts @@ -13,5 +13,20 @@ export default class GuildCreateListener extends BushListener { void client.console.info('guildCreate', `Joined <<${guild.name}>> with <<${guild.memberCount?.toLocaleString()}>> members.`); const g = await Guild.findByPk(guild.id); if (!g) void Guild.create({ id: guild.id }); + + const channel = await util.getConfigChannel('log'); + if (!channel) return; + return await channel.send({ + embeds: [ + { + color: util.colors.discord.GREEN, + description: `${util.emojis.join} Joined ${util.format.input( + guild.name + )} with **${guild.memberCount?.toLocaleString()}** members. I am now in **${client.guilds.cache.size}** guilds.`, + timestamp: new Date(), + footer: { text: `${guild.id}`, iconURL: guild.iconURL() ?? undefined } + } + ] + }); } } diff --git a/src/listeners/guild/guildDelete.ts b/src/listeners/guild/guildDelete.ts index 5480a7b..f036a8d 100644 --- a/src/listeners/guild/guildDelete.ts +++ b/src/listeners/guild/guildDelete.ts @@ -4,12 +4,27 @@ export default class GuildDeleteListener extends BushListener { public constructor() { super('guildDelete', { emitter: 'client', - event: 'guildDelete', //when the bot leaves a guild + event: 'guildDelete', // when the bot leaves a guild category: 'guild' }); } - public override exec(...[guild]: BushClientEvents['guildDelete']): void { + public override async exec(...[guild]: BushClientEvents['guildDelete']) { void client.console.info('guildDelete', `Left <<${guild.name}>> with <<${guild.memberCount?.toLocaleString()}>> members.`); + + const channel = await util.getConfigChannel('log'); + if (!channel) return; + return await channel.send({ + embeds: [ + { + color: util.colors.discord.RED, + description: `${util.emojis.leave} Left ${util.format.input( + guild.name + )} with **${guild.memberCount?.toLocaleString()}** members. I am now in **${client.guilds.cache.size}** guilds.`, + timestamp: new Date(), + footer: { text: `${guild.id}`, iconURL: guild.iconURL() ?? undefined } + } + ] + }); } } -- cgit