fixing event logs
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index f3c58fa..c4b488e 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -6,7 +6,7 @@
export async function callback(client: NucleusClient, emoji: GuildEmoji) {
const { getAuditLog, log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = client.logger;
if (!await isLogging(emoji.guild.id, "emojiUpdate")) return;
- const auditLog = (await getAuditLog(emoji.guild, AuditLogEvent.EmojiCreate))
+ const auditLog = (await getAuditLog(emoji.guild, AuditLogEvent.EmojiDelete))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0];
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index 59b4488..98ff558 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -7,7 +7,7 @@
const { getAuditLog, log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = client.logger;
if (!(await isLogging(newEmoji.guild.id, "emojiUpdate"))) return;
- const auditLog = (await getAuditLog(newEmoji.guild, AuditLogEvent.EmojiCreate))
+ const auditLog = (await getAuditLog(newEmoji.guild, AuditLogEvent.EmojiUpdate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === newEmoji.id)[0];
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index 81b2337..412ac96 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -1,15 +1,60 @@
import { AuditLogEvent, GuildAuditLogsEntry, GuildMember } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
+import type { LoggerOptions } from "../utils/log.js";
export const event = "guildMemberUpdate";
export async function callback(client: NucleusClient, before: GuildMember, after: GuildMember) {
- const { log, isLogging, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
- if (!await isLogging(after.guild.id, "memberUpdate")) return;
- const auditLog = (await getAuditLog(after.guild, AuditLogEvent.EmojiCreate))
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
+
+ const auditLog = (await getAuditLog(after.guild, AuditLogEvent.MemberUpdate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === after.id)[0];
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
+ if(!before.roles.cache.equals(after.roles.cache)) {
+ let rolesAdded = after.roles.cache.filter(role => !before.roles.cache.has(role.id));
+ let rolesRemoved = before.roles.cache.filter(role => !after.roles.cache.has(role.id));
+ let displayName = "Roles Removed";
+ let color = NucleusColors.red;
+ let emoji = "GUILD.ROLES.DELETE";
+ if(rolesAdded.size > 0 && rolesRemoved.size > 0) {displayName = "Roles Changed"; color = NucleusColors.yellow; emoji = "GUILD.ROLES.EDIT";}
+ else if(rolesAdded.size > 0) {displayName = "Roles Added"; color = NucleusColors.green; emoji = "GUILD.ROLES.CREATE";}
+ let removedEntry = rolesRemoved.map(role => role.id);
+ let addedEntry = rolesAdded.map(role => role.id);
+
+ let list = {
+ memberId: entry(after.id, `\`${after.id}\``),
+ name: entry(after.user.id, renderUser(after.user)),
+ changed: entry(Date.now(), renderDelta(Date.now())),
+ changedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!))
+ };
+
+ let data: LoggerOptions = {
+ meta: {
+ type: "memberUpdate",
+ displayName: displayName,
+ calculateType: "guildMemberUpdate",
+ color: color,
+ emoji: emoji,
+ timestamp: Date.now()
+ },
+ list: {
+
+ },
+ hidden: {
+ guild: after.guild.id
+ }
+ };
+
+ if(rolesAdded.size > 0) {
+ list = Object.assign(list, {rolesAdded: entry(addedEntry, addedEntry.map(id => `<@&${id}>`).join(", "))});
+ }
+ if(rolesRemoved.size > 0) {
+ list = Object.assign(list, {rolesRemoved: entry(removedEntry, removedEntry.map(id => `<@&${id}>`).join(", "))});
+ }
+ data = Object.assign(data, {list: list});
+ log(data);
+ }
if (before.nickname !== after.nickname) {
await client.database.history.create(
"nickname",
@@ -42,7 +87,8 @@
}
};
log(data);
- } else if (
+ }
+ if (
(before.communicationDisabledUntilTimestamp ?? 0) < Date.now() &&
(after.communicationDisabledUntil ?? 0) > Date.now()
) {
@@ -86,7 +132,8 @@
user: after.id,
expires: after.communicationDisabledUntilTimestamp
});
- } else if (
+ }
+ if (
after.communicationDisabledUntil === null &&
before.communicationDisabledUntilTimestamp !== null &&
Date.now() >= auditLog.createdTimestamp
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index 0996302..767e004 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -6,7 +6,7 @@
export async function callback(client: NucleusClient, sticker: Sticker) {
const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
if (!await isLogging(sticker.guild!.id, "stickerUpdate")) return;
- const auditLog = (await getAuditLog(sticker.guild!, AuditLogEvent.EmojiCreate))
+ const auditLog = (await getAuditLog(sticker.guild!, AuditLogEvent.StickerCreate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
const data = {