fixing event logs
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index dda37af..b42ded7 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -4,7 +4,8 @@
export const event = "channelCreate";
export async function callback(client: NucleusClient, channel: GuildBasedChannel) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const { getAuditLog, log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ if (!await isLogging(channel.guild.id, "channelUpdate")) return;
const auditLog = (await getAuditLog(channel.guild, AuditLogEvent.ChannelCreate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildBasedChannel)!.id === channel.id)[0];
if (!auditLog) return;
@@ -62,7 +63,7 @@
calculateType: "channelUpdate",
color: NucleusColors.green,
emoji: emoji,
- timestamp: channel.createdTimestamp
+ timestamp: channel.createdTimestamp ?? Date.now()
},
list: {
channelId: entry(channel.id, `\`${channel.id}\``),
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index a93e6c7..890a15f 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -14,7 +14,8 @@
export const event = "channelDelete";
export async function callback(client: NucleusClient, channel: GuildBasedChannel) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
+ const { getAuditLog, log, isLogging, NucleusColors, entry, renderDelta, renderUser } = client.logger;
+ if (!await isLogging(channel.guild.id, "channelUpdate")) return;
const auditLog = (await getAuditLog(channel.guild, AuditLogEvent.ChannelDelete))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildBasedChannel)!.id === channel.id)[0];
if (!auditLog) return;
@@ -81,7 +82,7 @@
),
nsfw: null,
created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp!)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ deleted: entry(Date.now(), renderDelta(Date.now())),
deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!))
};
if ((channel instanceof BaseGuildTextChannel || channel instanceof StageChannel) && channel.topic !== null)
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 6c8687e..052acc1 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -32,11 +32,11 @@
topic?: ReturnType<typeof entry>;
bitrate?: ReturnType<typeof entry>;
userLimit?: ReturnType<typeof entry>;
- rateLimitPerUser?: ReturnType<typeof entry>;
parent?: ReturnType<typeof entry>;
permissionOverwrites?: ReturnType<typeof entry>;
region?: ReturnType<typeof entry>;
maxUsers?: ReturnType<typeof entry>;
+ autoArchiveDuration?: ReturnType<typeof entry>;
}
@@ -44,8 +44,9 @@
export const event = "channelUpdate";
export async function callback(client: NucleusClient, oldChannel: GuildChannel, newChannel: GuildChannel) {
+ const { getAuditLog, log, isLogging, NucleusColors, renderDelta, renderUser, renderChannel } = client.logger;
+ if (!await isLogging(newChannel.guild.id, "channelUpdate")) return;
const config = await client.memory.readGuildInfo(newChannel.guild.id);
- const { getAuditLog, log, NucleusColors, renderDelta, renderUser, renderChannel } = client.logger;
entry = client.logger.entry;
if (newChannel.parent && newChannel.parent.id === config.tickets.category) return;
@@ -60,7 +61,7 @@
const changes: channelChanges = {
channelId: entry(newChannel.id, `\`${newChannel.id}\``),
channel: entry(newChannel.id, renderChannel(newChannel)),
- edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ edited: entry(Date.now(), renderDelta(Date.now())),
editedBy: entry(auditLog.executor!.id, renderUser((await newChannel.guild.members.fetch(auditLog.executor!.id)).user)),
};
if (oldChannel.name !== newChannel.name) changes.name = entry([oldChannel.name, newChannel.name], `${oldChannel.name} -> ${newChannel.name}`);
@@ -68,12 +69,16 @@
changes.position = entry([oldChannel.position.toString(), newChannel.position.toString()], `${oldChannel.position} -> ${newChannel.position}`);
switch (newChannel.type) {
+ case ChannelType.PrivateThread:
+ case ChannelType.PublicThread: {
+ return;
+ }
case ChannelType.GuildText: {
emoji = "CHANNEL.TEXT.EDIT";
readableType = "Text";
displayName = "Text Channel";
- let oldTopic = (oldChannel as TextChannel).topic,
- newTopic = (newChannel as TextChannel).topic;
+ let oldTopic = (oldChannel as TextChannel).topic ?? "*None*",
+ newTopic = (oldChannel as TextChannel).topic ?? "*None*";
if (oldTopic) {
if (oldTopic.length > 256)
oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
@@ -91,14 +96,20 @@
const nsfw = ["", ""];
nsfw[0] = (oldChannel as TextChannel).nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
nsfw[1] = (newChannel as TextChannel).nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
- if ((oldChannel as TextChannel).topic !== (newChannel as TextChannel).topic)
+ if (oldTopic !== newTopic)
changes.description = entry([(oldChannel as TextChannel).topic ?? "", (newChannel as TextChannel).topic ?? ""], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
if ((oldChannel as TextChannel).nsfw !== (newChannel as TextChannel).nsfw) changes.nsfw = entry([(oldChannel as TextChannel).nsfw ? "On" : "Off", (newChannel as TextChannel).nsfw ? "On" : "Off"], `${nsfw[0]} -> ${nsfw[1]}`);
- if ((oldChannel as TextChannel).rateLimitPerUser !== (newChannel as TextChannel).rateLimitPerUser && (oldChannel as TextChannel).rateLimitPerUser !== 0)
- changes.rateLimitPerUser = entry(
+ if ((oldChannel as TextChannel).rateLimitPerUser !== (newChannel as TextChannel).rateLimitPerUser)
+ changes.slowmode = entry(
[((oldChannel as TextChannel).rateLimitPerUser).toString(), ((newChannel as TextChannel).rateLimitPerUser).toString()],
`${humanizeDuration((oldChannel as TextChannel).rateLimitPerUser * 1000)} -> ${humanizeDuration((newChannel as TextChannel).rateLimitPerUser * 1000)}`
);
+ if((oldChannel as TextChannel).defaultAutoArchiveDuration !== (newChannel as TextChannel).defaultAutoArchiveDuration) {
+ changes.autoArchiveDuration = entry(
+ [((oldChannel as TextChannel).defaultAutoArchiveDuration ?? 4320).toString(), ((newChannel as TextChannel).defaultAutoArchiveDuration ?? 4320).toString()],
+ `${humanizeDuration(((oldChannel as TextChannel).defaultAutoArchiveDuration ?? 4320) * 60 * 1000)} -> ${humanizeDuration(((newChannel as TextChannel).defaultAutoArchiveDuration ?? 4320) * 60 * 1000)}`
+ );
+ }
break;
}
@@ -122,8 +133,15 @@
} else {
newTopic = "None";
}
- if ((oldChannel as TextChannel).nsfw !== (newChannel as TextChannel).nsfw)
+ if ((oldChannel as TextChannel).nsfw !== (newChannel as TextChannel).nsfw) {
changes.nsfw = entry([(oldChannel as TextChannel).nsfw ? "On" : "Off", (newChannel as TextChannel).nsfw ? "On" : "Off"], `${(oldChannel as TextChannel).nsfw ? "On" : "Off"} -> ${(newChannel as TextChannel).nsfw ? "On" : "Off"}`);
+ }
+ if((oldChannel as TextChannel).defaultAutoArchiveDuration !== (newChannel as TextChannel).defaultAutoArchiveDuration) {
+ changes.autoArchiveDuration = entry(
+ [((oldChannel as TextChannel).defaultAutoArchiveDuration ?? 4320).toString(), ((newChannel as TextChannel).defaultAutoArchiveDuration ?? 4320).toString()],
+ `${humanizeDuration(((oldChannel as TextChannel).defaultAutoArchiveDuration ?? 4320) * 60 * 1000)} -> ${humanizeDuration(((newChannel as TextChannel).defaultAutoArchiveDuration ?? 4320) * 60 * 1000)}`
+ );
+ }
break;
}
case ChannelType.GuildVoice: {
@@ -174,7 +192,7 @@
if ((oldChannel as StageChannel).rtcRegion !== (newChannel as StageChannel).rtcRegion)
changes.region = entry(
[(oldChannel as StageChannel).rtcRegion ?? "Automatic", (newChannel as StageChannel).rtcRegion ?? "Automatic"],
- `${capitalize((oldChannel as StageChannel).rtcRegion?.toUpperCase() ?? "automatic")} -> ${capitalize((newChannel as StageChannel).rtcRegion?.toUpperCase() ?? "automatic")}`
+ `${capitalize((oldChannel as StageChannel).rtcRegion?.toLowerCase() ?? "automatic")} -> ${capitalize((newChannel as StageChannel).rtcRegion?.toLowerCase() ?? "automatic")}`
);
break;
}
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 8023abc..2630295 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -4,9 +4,10 @@
export const event = "emojiCreate";
export async function callback(client: NucleusClient, emoji: GuildEmoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = client.logger;
+ 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))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0];
+ .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0];
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
const data = {
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index f607cf4..f3c58fa 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -4,7 +4,8 @@
export const event = "emojiDelete";
export async function callback(client: NucleusClient, emoji: GuildEmoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = client.logger;
+ 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))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0];
if (!auditLog) return;
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index 201dd42..59b4488 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -4,7 +4,8 @@
export const event = "emojiUpdate";
export async function callback(client: NucleusClient, oldEmoji: GuildEmoji, newEmoji: GuildEmoji) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger;
+ 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))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === newEmoji.id)[0];
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index 3d96245..cac4b41 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -7,10 +7,11 @@
export const event = "guildBanAdd";
export async function callback(client: NucleusClient, ban: GuildBan) {
+ const { log, isLogging, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
await statsChannelRemove(client, undefined, ban.guild, ban.user);
purgeByUser(ban.user.id, ban.guild.id);
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
- const auditLog: GuildAuditLogsEntry | undefined = (await getAuditLog(ban.guild, AuditLogEvent.EmojiCreate))
+ if (!(await isLogging(ban.guild.id, "guildMemberPunish"))) return;
+ const auditLog: GuildAuditLogsEntry | undefined = (await getAuditLog(ban.guild, AuditLogEvent.MemberBanAdd))
.filter((entry: GuildAuditLogsEntry) => ((entry.target! as User).id === ban.user.id))[0];
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
@@ -22,12 +23,12 @@
calculateType: "guildMemberPunish",
color: NucleusColors.red,
emoji: "PUNISH.BAN.RED",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
memberId: entry(ban.user.id, `\`${ban.user.id}\``),
name: entry(ban.user.id, renderUser(ban.user)),
- banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ banned: entry(Date.now(), renderDelta(Date.now())),
bannedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
reason: entry(auditLog.reason, auditLog.reason ? `\n> ${auditLog.reason}` : "*No reason provided.*"),
accountCreated: entry(ban.user.createdTimestamp, renderDelta(ban.user.createdTimestamp)),
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index bcb70d5..3be4560 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -1,14 +1,13 @@
import type { GuildAuditLogsEntry, GuildBan, User } from "discord.js";
import { AuditLogEvent } from "discord.js";
-import { purgeByUser } from "../actions/tickets/delete.js";
import type { NucleusClient } from "../utils/client.js";
export const event = "guildBanRemove";
export async function callback(client: NucleusClient, ban: GuildBan) {
- purgeByUser(ban.user.id, ban.guild.id);
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
- const auditLog = (await getAuditLog(ban.guild, AuditLogEvent.EmojiCreate))
+ const { log, isLogging, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
+ if (!await isLogging(ban.guild.id, "guildMemberPunish")) return;
+ const auditLog = (await getAuditLog(ban.guild, AuditLogEvent.MemberBanRemove))
.filter((entry: GuildAuditLogsEntry) => ((entry.target! as User).id === ban.user.id))[0];
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
@@ -20,12 +19,12 @@
calculateType: "guildMemberPunish",
color: NucleusColors.green,
emoji: "PUNISH.BAN.GREEN",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
memberId: entry(ban.user.id, `\`${ban.user.id}\``),
name: entry(ban.user.id, renderUser(ban.user)),
- unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ unbanned: entry(Date.now(), renderDelta(Date.now())),
unbannedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
accountCreated: entry(ban.user.createdTimestamp, renderDelta(ban.user.createdTimestamp))
},
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index d25c9c4..81b2337 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -4,7 +4,8 @@
export const event = "guildMemberUpdate";
export async function callback(client: NucleusClient, before: GuildMember, after: GuildMember) {
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
+ 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))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === after.id)[0];
if (!auditLog) return;
@@ -26,14 +27,14 @@
calculateType: "guildMemberUpdate",
color: NucleusColors.yellow,
emoji: "PUNISH.NICKNAME.YELLOW",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
memberId: entry(after.id, `\`${after.id}\``),
name: entry(after.user.id, renderUser(after.user)),
before: entry(before.nickname, before.nickname ? before.nickname : "*None*"),
after: entry(after.nickname, after.nickname ? after.nickname : "*None*"),
- changed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ changed: entry(Date.now(), renderDelta(Date.now())),
changedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!))
},
hidden: {
@@ -42,8 +43,8 @@
};
log(data);
} else if (
- (before.communicationDisabledUntilTimestamp ?? 0) < new Date().getTime() &&
- (after.communicationDisabledUntil ?? 0) > new Date().getTime()
+ (before.communicationDisabledUntilTimestamp ?? 0) < Date.now() &&
+ (after.communicationDisabledUntil ?? 0) > Date.now()
) {
await client.database.history.create(
"mute",
@@ -62,7 +63,7 @@
calculateType: "guildMemberPunish",
color: NucleusColors.yellow,
emoji: "PUNISH.MUTE.YELLOW",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
memberId: entry(after.id, `\`${after.id}\``),
@@ -71,7 +72,7 @@
after.communicationDisabledUntilTimestamp,
renderDelta(after.communicationDisabledUntilTimestamp!)
),
- muted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ muted: entry(Date.now(), renderDelta(Date.now())),
mutedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
reason: entry(auditLog.reason, auditLog.reason ? auditLog.reason : "\n> *No reason provided*")
},
@@ -88,7 +89,7 @@
} else if (
after.communicationDisabledUntil === null &&
before.communicationDisabledUntilTimestamp !== null &&
- new Date().getTime() >= auditLog.createdTimestamp
+ Date.now() >= auditLog.createdTimestamp
) {
await client.database.history.create(
"unmute",
@@ -107,12 +108,12 @@
calculateType: "guildMemberPunish",
color: NucleusColors.green,
emoji: "PUNISH.MUTE.GREEN",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
memberId: entry(after.id, `\`${after.id}\``),
name: entry(after.user.id, renderUser(after.user)),
- unmuted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ unmuted: entry(Date.now(), renderDelta(Date.now())),
unmutedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!))
},
hidden: {
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index 8690af2..6b25e48 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -6,7 +6,8 @@
export async function callback(client: NucleusClient, before: Guild, after: Guild) {
await statsChannelUpdate(client, after.members.me!);
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ if (!await isLogging(after.id, "guildUpdate")) return;
const auditLog = (await getAuditLog(after, AuditLogEvent.GuildUpdate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Guild)!.id === after.id)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
@@ -74,7 +75,7 @@
);
if (!Object.keys(list).length) return;
- list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+ list["updated"] = entry(Date.now(), renderDelta(Date.now()));
list["updatedBy"] = entry(auditLog.executor!.id, renderUser(auditLog.executor!));
const data = {
meta: {
@@ -83,7 +84,7 @@
calculateType: "guildUpdate",
color: NucleusColors.yellow,
emoji: "GUILD.YELLOW",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: list,
hidden: {
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index a267f09..34f66dc 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -7,7 +7,8 @@
export async function callback(client: NucleusClient, invite: Invite) {
if(!invite.guild) return; // This is a DM invite (not a guild invite
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ if (!await isLogging(invite.guild.id, "guildUpdate")) return;
const auditLog = (await getAuditLog(invite.guild as Guild, AuditLogEvent.InviteCreate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Invite)!.code === invite.code)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
@@ -18,7 +19,7 @@
calculateType: "guildUpdate",
color: NucleusColors.green,
emoji: "INVITE.CREATE",
- timestamp: invite.createdTimestamp
+ timestamp: invite.createdTimestamp ?? Date.now()
},
list: {
channel: entry(invite.channel!.id, renderChannel(invite.channel as GuildChannel)),
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index 1ded432..456af90 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -7,7 +7,8 @@
export async function callback(client: NucleusClient, invite: Invite) {
if(!invite.guild) return; // This is a DM invite (not a guild invite
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ if (!await isLogging(invite.guild.id, "guildUpdate")) return;
const auditLog = (await getAuditLog(invite.guild as Guild, AuditLogEvent.InviteDelete))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Invite)!.code === invite.code)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
@@ -18,14 +19,14 @@
calculateType: "guildUpdate",
color: NucleusColors.red,
emoji: "INVITE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
channel: entry(invite.channel!.id, renderChannel(invite.channel as GuildChannel)),
link: entry(invite.url, invite.url),
expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ deleted: entry(Date.now(), renderDelta(Date.now()))
},
hidden: {
guild: invite.guild!.id
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index daf195a..77b111f 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -8,7 +8,8 @@
export async function callback(client: NucleusClient, member: GuildMember) {
welcome(client, member);
statsChannelAdd(client, member);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ const { log, isLogging, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ if (!await isLogging(member.guild.id, "guildMemberUpdate")) return;
await client.database.history.create("join", member.guild.id, member.user, null, null);
const data = {
meta: {
@@ -17,7 +18,7 @@
calculateType: "guildMemberUpdate",
color: NucleusColors.green,
emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN",
- timestamp: member.joinedTimestamp
+ timestamp: member.joinedTimestamp ?? Date.now()
},
list: {
memberId: entry(member.id, `\`${member.id}\``),
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index e70fb3c..8b3d1b1 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -7,22 +7,36 @@
export const event = "guildMemberRemove";
export async function callback(client: NucleusClient, member: GuildMember) {
+ const startTime = Date.now() - 10 * 1000;
purgeByUser(member.id, member.guild.id);
await statsChannelRemove(client, member);
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- const auditLog = (await getAuditLog(member.guild as Guild, AuditLogEvent.MemberKick))
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ if (!await isLogging(member.guild.id, "guildMemberUpdate")) return;
+ const kickAuditLog = (await getAuditLog(member.guild as Guild, AuditLogEvent.MemberKick))
+ .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === member.id)[0];
+ const banAuditLog = (await getAuditLog(member.guild as Guild, AuditLogEvent.MemberBanAdd))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === member.id)[0];
let type = "leave";
- if (auditLog) {
- if (auditLog.executor!.id === client.user!.id) return;
- if (auditLog.createdAt.valueOf() - 100 >= new Date().getTime()) {
+ if (kickAuditLog) {
+ if (kickAuditLog.executor!.id === client.user!.id) return;
+ if (kickAuditLog.createdAt.getTime() >= startTime) {
type = "kick";
}
}
+ if (banAuditLog) {
+ if (banAuditLog.executor!.id === client.user!.id) return;
+ if (banAuditLog.createdAt.getTime() >= startTime) {
+ if (!kickAuditLog) {
+ return
+ } else if (kickAuditLog.createdAt.valueOf() < banAuditLog.createdAt.valueOf()) {
+ return
+ }
+ }
+ }
let data;
if (type === "kick") {
- if (!auditLog) return;
- await client.database.history.create("kick", member.guild.id, member.user, auditLog.executor, auditLog.reason);
+ if (!kickAuditLog) return;
+ await client.database.history.create("kick", member.guild.id, member.user, kickAuditLog.executor, kickAuditLog.reason);
data = {
meta: {
type: "memberKick",
@@ -30,15 +44,15 @@
calculateType: "guildMemberPunish",
color: NucleusColors.red,
emoji: "PUNISH.KICK.RED",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
joined: entry(member.joinedTimestamp, renderDelta(member.joinedTimestamp?.valueOf()!)),
- kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- kickedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
- reason: entry(auditLog.reason, auditLog.reason ? `\n> ${auditLog.reason}` : "*No reason provided.*"),
+ kicked: entry(Date.now(), renderDelta(Date.now())),
+ kickedBy: entry(kickAuditLog.executor!.id, renderUser(kickAuditLog.executor!)),
+ reason: entry(kickAuditLog.reason, kickAuditLog.reason ? `\n> ${kickAuditLog.reason}` : "*No reason provided.*"),
accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp)),
serverMemberCount: member.guild.memberCount
},
@@ -55,13 +69,13 @@
calculateType: "guildMemberUpdate",
color: NucleusColors.red,
emoji: "MEMBER." + (member.user.bot ? "BOT." : "") + "LEAVE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
memberId: entry(member.id, `\`${member.id}\``),
name: entry(member.id, renderUser(member.user)),
joined: entry(member.joinedTimestamp, renderDelta(member.joinedTimestamp?.valueOf()!)),
- left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ left: entry(Date.now(), renderDelta(Date.now())),
accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp)),
serverMemberCount: member.guild.memberCount
},
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index 0a62019..7f8e5d1 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -19,7 +19,7 @@
console.log(e);
}
- const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const { log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
const fileNames = await logAttachment(message);
@@ -45,7 +45,7 @@
messageId: entry(message.id, `\`${message.id}\``),
sentBy: entry(message.author.id, renderUser(message.author)),
sentIn: entry(message.channel.id, renderChannel(message.channel)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ deleted: entry(Date.now(), renderDelta(Date.now())),
mentions: message.mentions.users.size,
attachments: entry(message.attachments.size, message.attachments.size + attachmentJump),
repliedTo: entry(
@@ -68,7 +68,7 @@
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start:
@@ -105,7 +105,7 @@
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start:
@@ -140,7 +140,7 @@
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start:
@@ -170,7 +170,7 @@
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start:
@@ -201,7 +201,7 @@
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start:
@@ -233,7 +233,7 @@
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start:
@@ -265,7 +265,7 @@
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start:
@@ -283,6 +283,7 @@
}
if (config.filters.pings.everyone && message.mentions.everyone) {
+ if(!await isLogging(message.guild.id, "messageMassPing")) return;
const data = {
meta: {
type: "everyonePing",
@@ -290,7 +291,7 @@
calculateType: "messageMassPing",
color: NucleusColors.yellow,
emoji: "MESSAGE.PING.EVERYONE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
@@ -307,6 +308,7 @@
if (!config.filters.pings.allowed.roles.includes(roleId)) {
messageException(message.guild.id, message.channel.id, message.id);
await message.delete();
+ if(!await isLogging(message.guild.id, "messageMassPing")) return;
const data = {
meta: {
type: "rolePing",
@@ -314,7 +316,7 @@
calculateType: "messageMassPing",
color: NucleusColors.yellow,
emoji: "MESSAGE.PING.ROLE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start: content
@@ -333,6 +335,7 @@
if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
messageException(message.guild.id, message.channel.id, message.id);
await message.delete();
+ if(!await isLogging(message.guild.id, "messageMassPing")) return;
const data = {
meta: {
type: "massPing",
@@ -340,7 +343,7 @@
calculateType: "messageMassPing",
color: NucleusColors.yellow,
emoji: "MESSAGE.PING.MASS",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 65e1422..aac83f4 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -7,11 +7,12 @@
if (message.author.id === client.user!.id) return;
if (message.author.bot) return;
if (client.noLog.includes(`${message.guild!.id}/${message.channel.id}/${message.id}`)) return;
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ if (!await isLogging(message.guild!.id, "messageDelete")) return;
const auditLog = (await getAuditLog(message.guild!, AuditLogEvent.MemberBanAdd))
.filter((entry: GuildAuditLogsEntry) => (entry.target! as User).id === message.author.id)[0];
if (auditLog) {
- if (auditLog.createdTimestamp - 1000 < new Date().getTime()) return;
+ if (auditLog.createdTimestamp - 1000 < Date.now()) return;
}
const replyTo = message.reference;
let content = message.cleanContent;
@@ -35,7 +36,7 @@
calculateType: "messageDelete",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
separate: {
start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
@@ -44,7 +45,7 @@
messageId: entry(message.id, `\`${message.id}\``),
sentBy: entry(message.author.id, renderUser(message.author)),
sentIn: entry(message.channel.id, renderChannel(message.channel as Discord.GuildChannel | Discord.ThreadChannel)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ deleted: entry(Date.now(), renderDelta(Date.now())),
mentions: message.mentions.users.size,
attachments: entry(attachments, attachments + attachmentJump),
repliedTo: entry(
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index d491641..f5a28a4 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -8,7 +8,8 @@
if (newMessage.author.id === client.user!.id) return;
if (newMessage.author.bot) return;
if (!newMessage.guild) return;
- const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = client.logger;
+ const { log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = client.logger;
+
const replyTo: MessageReference | null = newMessage.reference;
let newContent = newMessage.cleanContent.replaceAll("`", "‘");
let oldContent = oldMessage.cleanContent.replaceAll("`", "‘");
@@ -20,6 +21,7 @@
attachmentJump = ` [[View attachments]](${config})`;
}
if (newMessage.crosspostable !== oldMessage.crosspostable) {
+ if(!await isLogging(newMessage.guild.id, "messageAnnounce")) return;
if (!replyTo) {
const data = {
meta: {
@@ -28,7 +30,7 @@
calculateType: "messageAnnounce",
color: NucleusColors.yellow,
emoji: "MESSAGE.CREATE",
- timestamp: newMessage.editedTimestamp
+ timestamp: newMessage.editedTimestamp ?? Date.now()
},
separate: {
end: `[[Jump to message]](${newMessage.url})`
@@ -58,6 +60,7 @@
return log(data);
}
}
+ if (!await isLogging(newMessage.guild.id, "messageUpdate")) return;
if (!newMessage.editedTimestamp) {
return;
}
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index d253ce7..be385f0 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -4,7 +4,8 @@
export const event = "roleCreate";
export async function callback(client: NucleusClient, role: Role) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = client.logger;
+ if (!await isLogging(role.guild.id, "guildRoleUpdate")) return;
if (role.managed) return;
const auditLog = (await getAuditLog(role.guild as Guild, AuditLogEvent.RoleCreate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Role)!.id === role.id)[0]!;
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index f41241b..b207f4f 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -5,7 +5,8 @@
export const event = "roleDelete";
export async function callback(client: NucleusClient, role: Role) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ if (!await isLogging(role.guild.id, "guildRoleUpdate")) return;
if (role.managed) return;
const auditLog = (await getAuditLog(role.guild as Guild, AuditLogEvent.RoleDelete))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Role)!.id === role.id)[0]!;
@@ -34,7 +35,7 @@
members: entry(role.members.size, `${role.members.size}`),
deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ deleted: entry(Date.now(), renderDelta(Date.now()))
},
hidden: {
guild: role.guild.id
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 09e062f..8d9ef10 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -5,8 +5,8 @@
export const event = "roleUpdate";
export async function callback(client: NucleusClient, oldRole: Role, newRole: Role) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger;
-
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger;
+ if (!await isLogging(newRole.guild.id, "guildRoleUpdate")) return;
const auditLog = (await getAuditLog(newRole.guild as Guild, AuditLogEvent.RoleUpdate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Role)!.id === newRole.id)[0];
if (!auditLog) return;
@@ -15,7 +15,7 @@
const changes: Record<string, ReturnType<typeof entry>> = {
roleId: entry(newRole.id, `\`${newRole.id}\``),
role: entry(newRole.id, renderRole(newRole)),
- edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ edited: entry(Date.now(), renderDelta(Date.now())),
editedBy: entry(auditLog.executor!.id, renderUser((await newRole.guild.members.fetch(auditLog.executor!.id)).user))
};
const mentionable = ["", ""];
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index b341ae9..0996302 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -4,7 +4,8 @@
export const event = "stickerDelete";
export async function callback(client: NucleusClient, sticker: Sticker) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ 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))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index ce26a85..fcfc3a6 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -4,7 +4,8 @@
export const event = "stickerDelete";
export async function callback(client: NucleusClient, sticker: Sticker) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ 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.StickerDelete))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
@@ -14,8 +15,8 @@
displayName: "Sticker Deleted",
calculateType: "stickerUpdate",
color: NucleusColors.red,
- sticker: "GUILD.sticker.DELETE",
- timestamp: auditLog.createdTimestamp
+ emoji: "GUILD.STICKER.DELETE",
+ timestamp: auditLog.createdTimestamp ?? Date.now()
},
list: {
stickerId: entry(sticker.id, `\`${sticker.id}\``),
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index ed01b71..aef28a4 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -4,8 +4,8 @@
export const event = "stickerUpdate";
export async function callback(client: NucleusClient, oldSticker: Sticker, newSticker: Sticker) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
-
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
+ if (!await isLogging(newSticker.guild!.id, "stickerUpdate")) return;
if (oldSticker.name === newSticker.name) return;
const auditLog = (await getAuditLog(newSticker.guild!, AuditLogEvent.StickerUpdate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === newSticker.id)[0]!;
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index 6d3225c..f56e1bb 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -5,7 +5,8 @@
export const event = "threadCreate";
export async function callback(client: NucleusClient, thread: ThreadChannel) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ if (!await isLogging(thread.guild.id, "channelUpdate")) return;
const auditLog = (await getAuditLog(thread.guild, AuditLogEvent.ThreadCreate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as ThreadChannel)!.id === thread.id)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
@@ -22,7 +23,7 @@
calculateType: "channelUpdate",
color: NucleusColors.green,
emoji: "CHANNEL.TEXT.CREATE",
- timestamp: thread.createdTimestamp
+ timestamp: thread.createdTimestamp ?? Date.now()
},
list: {
threadId: entry(thread.id, `\`${thread.id}\``),
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index 429f63a..bfac75e 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -5,7 +5,8 @@
export const event = "threadDelete";
export async function callback(client: NucleusClient, thread: ThreadChannel) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ if (!await isLogging(thread.guild.id, "channelUpdate")) return;
const auditLog = (await getAuditLog(thread.guild, AuditLogEvent.ThreadDelete))
.filter((entry: GuildAuditLogsEntry) => (entry.target as ThreadChannel)!.id === thread.id)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
@@ -22,7 +23,7 @@
calculateType: "channelUpdate",
color: NucleusColors.red,
emoji: "CHANNEL.TEXT.DELETE",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: {
threadId: entry(thread.id, `\`${thread.id}\``),
@@ -38,7 +39,7 @@
membersInThread: entry(thread.memberCount, thread.memberCount!.toString()),
deletedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!)),
created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp!)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ deleted: entry(Date.now(), renderDelta(Date.now()))
},
hidden: {
guild: thread.guild.id
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 555b17f..af792bc 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -6,7 +6,8 @@
export const event = "threadUpdate";
export async function callback(client: NucleusClient, oldThread: ThreadChannel, newThread: ThreadChannel) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ if (!await isLogging(newThread.guild.id, "channelUpdate")) return;
const auditLog = (await getAuditLog(newThread.guild, AuditLogEvent.ThreadUpdate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as ThreadChannel)!.id === newThread.id)[0]!;
if (auditLog.executor!.id === client.user!.id) return;
@@ -37,7 +38,7 @@
);
}
if (!(Object.keys(list).length - 3)) return;
- list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+ list["updated"] = entry(Date.now(), renderDelta(Date.now()));
list["updatedBy"] = entry(auditLog.executor!.id, renderUser(auditLog.executor!));
const data = {
meta: {
@@ -46,7 +47,7 @@
calculateType: "channelUpdate",
color: NucleusColors.yellow,
emoji: "CHANNEL.TEXT.EDIT",
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: list,
hidden: {
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index e5f07dd..fb18f48 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -10,7 +10,8 @@
export async function callback(client: NucleusClient, channel: Discord.GuildChannel) {
try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
+ const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
+ if (!await isLogging(channel.guild.id, "webhookUpdate")) return;
const auditCreate = (await getAuditLog(channel.guild, AuditLogEvent.WebhookCreate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as Webhook)!.id === channel.id)[0]!;
const auditDelete = (await getAuditLog(channel.guild, AuditLogEvent.WebhookDelete))
@@ -46,7 +47,7 @@
(auditUpdate.target! as Extract<GuildAuditLogsEntry, {createdTimestamp: number}>).createdTimestamp,
renderDelta((auditUpdate.target! as Extract<GuildAuditLogsEntry, {createdTimestamp: number}>).createdTimestamp)
);
- list["edited"] = entry(after["editedTimestamp"]!, renderDelta(new Date().getTime()));
+ list["edited"] = entry(after["editedTimestamp"]!, renderDelta(Date.now()));
list["editedBy"] = entry(auditUpdate.executor!.id, renderUser(auditUpdate.executor!));
action = "Update";
} else if (deleteTimestamp > createTimestamp && deleteTimestamp > updateTimestamp && auditDelete) {
@@ -61,7 +62,7 @@
name: entry(before["name"]!, `${before["name"]}`),
channel: entry(before["channel_id"]!, renderChannel((await client.channels.fetch(before["channel_id"]!)) as GuildChannel)),
created: entry((auditDelete.target! as Extract<GuildAuditLogsEntry, {createdTimestamp: number}>).createdTimestamp, renderDelta((auditDelete.target! as Extract<GuildAuditLogsEntry, {createdTimestamp: number}>).createdTimestamp)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ deleted: entry(Date.now(), renderDelta(Date.now())),
deletedBy: entry(
auditDelete.executor!.id,
renderUser((await channel.guild.members.fetch(auditDelete.executor!.id)).user)
@@ -83,7 +84,7 @@
auditCreate.executor!.id,
renderUser((await channel.guild.members.fetch(auditCreate.executor!.id)).user)
),
- created: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ created: entry(Date.now(), renderDelta(Date.now()))
};
}
const cols = {
@@ -98,7 +99,7 @@
calculateType: "webhookUpdate",
color: NucleusColors[cols[action] as keyof typeof NucleusColors],
emoji: "WEBHOOK." + action.toUpperCase(),
- timestamp: new Date().getTime()
+ timestamp: Date.now()
},
list: list,
hidden: {