From 86dc81d497c13e81ba4a21a67523572c89c5c5e5 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Tue, 22 Nov 2022 17:38:40 +1100 Subject: [PATCH] it do be super hot fr --- src/events/guildBanAdd.ts | 2 +- src/events/guildBanRemove.ts | 2 +- src/events/roleUpdate.ts | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/events/roleUpdate.ts diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts index 769c87a..97e77b9 100644 --- a/src/events/guildBanAdd.ts +++ b/src/events/guildBanAdd.ts @@ -12,7 +12,7 @@ export default { const {executor, target, reason } = banLog; if (target.id == member.user.id) { const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Banned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields( - {name: '🔹 Moderator', value: `<@${executor.id}> (\`${executor.id}\`)`}, + {name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``}, {name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified': reason}`} ); (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]}) diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts index 2230c58..4a9f191 100644 --- a/src/events/guildBanRemove.ts +++ b/src/events/guildBanRemove.ts @@ -12,7 +12,7 @@ export default { const { executor, target, reason } = unbanLog; if (target.id == member.user.id) { const embed = new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Unbanned: ${target.tag}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields( - {name: '🔹 Moderator', value: `<@${executor.id}> (\`${executor.id}\`)`}, + {name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``}, {name: '🔹 Reason', value: `${reason == null ? 'Reason unspecified.': reason}`} ); (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]}) diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts new file mode 100644 index 0000000..d495cda --- /dev/null +++ b/src/events/roleUpdate.ts @@ -0,0 +1,23 @@ +import Discord, { AuditLogEvent } from 'discord.js'; +import { TClient } from '../client'; +export default { + name: 'roleUpdate', + execute: async(client:TClient, oldRole:Discord.Role, newRole:Discord.Role)=>{ + const fetchRoleUpdoot = await client.guilds.cache.get(oldRole.guild.id).fetchAuditLogs({ + limit: 1, + type: AuditLogEvent.RoleUpdate + }) + const roleLog = fetchRoleUpdoot.entries.first(); + if (!roleLog) return + const {executor, target} = roleLog; + if (target) { + const embed = new client.embed().setColor(newRole.hexColor).setTimestamp().setTitle(`Role modified: ${oldRole.name}`).setDescription(`🔹 **Role**\n${target}\n\`${target.id}\``).addFields( + {name: `${executor.bot ? '🔹 Bot' : '🔹 Admin'}`, value: `<@${executor.id}>\n\`${executor.id}\``}, + {name: '🔹 Role changes', value: `**Old color:** ${oldRole.hexColor}\n**New color:** ${newRole.hexColor}`} + ); + (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]}) + } else { + console.log(`${target.id} was modified from ${client.guilds.cache.get(oldRole.guild.name)} but no audit log could be fetched.`) + } + } +} \ No newline at end of file