Reformat using prettier
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index b42ded7..90a7f6d 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -5,9 +5,10 @@
export async function callback(client: NucleusClient, channel: GuildBasedChannel) {
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 (!(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;
if (auditLog.executor!.id === client.user!.id) return;
let emoji;
@@ -81,4 +82,4 @@
}
};
log(data);
-};
+}
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index 890a15f..8dffd38 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -15,9 +15,10 @@
export async function callback(client: NucleusClient, channel: GuildBasedChannel) {
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 (!(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;
if (auditLog.executor!.id === client.user!.id) return;
@@ -30,32 +31,38 @@
readableType = "Text";
displayName = "Text Channel";
break;
- } case ChannelType.GuildAnnouncement: {
+ }
+ case ChannelType.GuildAnnouncement: {
emoji = "CHANNEL.TEXT.DELETE";
readableType = "Announcement";
displayName = "Announcement Channel";
break;
- } case ChannelType.GuildVoice: {
+ }
+ case ChannelType.GuildVoice: {
emoji = "CHANNEL.VOICE.DELETE";
readableType = "Voice";
displayName = "Voice Channel";
break;
- } case ChannelType.GuildCategory: {
+ }
+ case ChannelType.GuildCategory: {
emoji = "CHANNEL.CATEGORY.DELETE";
readableType = "Category";
displayName = "Category";
break;
- } case ChannelType.GuildStageVoice: {
+ }
+ case ChannelType.GuildStageVoice: {
emoji = "CHANNEL.VOICE.DELETE";
readableType = "Stage";
displayName = "Stage Channel";
break;
- } case ChannelType.GuildForum: {
+ }
+ case ChannelType.GuildForum: {
emoji = "CHANNEL.TEXT.DELETE";
readableType = "Forum";
displayName = "Forum Channel";
break;
- } default: {
+ }
+ default: {
emoji = "CHANNEL.TEXT.DELETE";
readableType = "Channel";
displayName = "Channel";
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 052acc1..6491cc9 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -1,5 +1,5 @@
-import { GuildChannel, AuditLogEvent, ChannelType, TextChannel, VoiceChannel, StageChannel } from 'discord.js';
-import type { GuildAuditLogsEntry } from 'discord.js';
+import { GuildChannel, AuditLogEvent, ChannelType, TextChannel, VoiceChannel, StageChannel } from "discord.js";
+import type { GuildAuditLogsEntry } from "discord.js";
//@ts-expect-error
import humanizeDuration from "humanize-duration";
import type { NucleusClient } from "../utils/client.js";
@@ -10,12 +10,12 @@
let entry = c.logger.entry;
const channelTypeEmoji: Record<number, string> = {
- 0: "Text", // Text channel
- 2: "Voice", // Voice channel
- 5: "Announcement", // Announcement channel
- 13: "Stage", // Stage channel
- 15: "Forum", // Forum channel
- 99: "Rules" // Rules channel
+ 0: "Text", // Text channel
+ 2: "Voice", // Voice channel
+ 5: "Announcement", // Announcement channel
+ 13: "Stage", // Stage channel
+ 15: "Forum", // Forum channel
+ 99: "Rules" // Rules channel
};
interface channelChanges {
@@ -39,19 +39,20 @@
autoArchiveDuration?: ReturnType<typeof entry>;
}
-
-
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;
+ if (!(await isLogging(newChannel.guild.id, "channelUpdate"))) return;
const config = await client.memory.readGuildInfo(newChannel.guild.id);
entry = client.logger.entry;
if (newChannel.parent && newChannel.parent.id === config.tickets.category) return;
- const auditLog: null | GuildAuditLogsEntry<AuditLogEvent.ChannelUpdate> = (await getAuditLog(newChannel.guild, AuditLogEvent.ChannelUpdate))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildChannel)!.id === newChannel.id)[0] as GuildAuditLogsEntry<AuditLogEvent.ChannelUpdate> | null;
+ const auditLog: null | GuildAuditLogsEntry<AuditLogEvent.ChannelUpdate> = (
+ await getAuditLog(newChannel.guild, AuditLogEvent.ChannelUpdate)
+ ).filter(
+ (entry: GuildAuditLogsEntry) => (entry.target as GuildChannel)!.id === newChannel.id
+ )[0] as GuildAuditLogsEntry<AuditLogEvent.ChannelUpdate> | null;
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
@@ -62,11 +63,18 @@
channelId: entry(newChannel.id, `\`${newChannel.id}\``),
channel: entry(newChannel.id, renderChannel(newChannel)),
edited: entry(Date.now(), renderDelta(Date.now())),
- editedBy: entry(auditLog.executor!.id, renderUser((await newChannel.guild.members.fetch(auditLog.executor!.id)).user)),
+ 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}`);
+ if (oldChannel.name !== newChannel.name)
+ changes.name = entry([oldChannel.name, newChannel.name], `${oldChannel.name} -> ${newChannel.name}`);
if (oldChannel.position !== newChannel.position)
- changes.position = entry([oldChannel.position.toString(), newChannel.position.toString()], `${oldChannel.position} -> ${newChannel.position}`);
+ changes.position = entry(
+ [oldChannel.position.toString(), newChannel.position.toString()],
+ `${oldChannel.position} -> ${newChannel.position}`
+ );
switch (newChannel.type) {
case ChannelType.PrivateThread:
@@ -94,20 +102,46 @@
newTopic = "None";
}
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`;
+ 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 (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]}`);
+ 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)
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)}`
+ [
+ (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) {
+ 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)}`
+ [
+ ((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
+ )}`
);
}
@@ -134,12 +168,27 @@
newTopic = "None";
}
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"}`);
+ 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) {
+ 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)}`
+ [
+ ((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;
@@ -149,16 +198,29 @@
readableType = "Voice";
displayName = "Voice Channel";
if ((oldChannel as VoiceChannel).bitrate !== (newChannel as VoiceChannel).bitrate)
- changes.bitrate = entry([(oldChannel as VoiceChannel).bitrate.toString(), (newChannel as VoiceChannel).bitrate.toString()], `${(oldChannel as VoiceChannel).bitrate} -> ${(newChannel as VoiceChannel).bitrate}`);
+ changes.bitrate = entry(
+ [(oldChannel as VoiceChannel).bitrate.toString(), (newChannel as VoiceChannel).bitrate.toString()],
+ `${(oldChannel as VoiceChannel).bitrate} -> ${(newChannel as VoiceChannel).bitrate}`
+ );
if ((oldChannel as VoiceChannel).userLimit !== (newChannel as VoiceChannel).userLimit)
changes.maxUsers = entry(
- [(oldChannel as VoiceChannel).userLimit.toString(), (newChannel as VoiceChannel).userLimit.toString()],
- `${(oldChannel as VoiceChannel).userLimit ? (oldChannel as VoiceChannel).userLimit : "Unlimited"} -> ${(newChannel as VoiceChannel).userLimit}`
+ [
+ (oldChannel as VoiceChannel).userLimit.toString(),
+ (newChannel as VoiceChannel).userLimit.toString()
+ ],
+ `${
+ (oldChannel as VoiceChannel).userLimit ? (oldChannel as VoiceChannel).userLimit : "Unlimited"
+ } -> ${(newChannel as VoiceChannel).userLimit}`
);
if ((oldChannel as VoiceChannel).rtcRegion !== (newChannel as VoiceChannel).rtcRegion)
changes.region = entry(
- [(oldChannel as VoiceChannel).rtcRegion ?? "automatic", (newChannel as VoiceChannel).rtcRegion ?? "automatic"],
- `${capitalize((oldChannel as VoiceChannel).rtcRegion?.toUpperCase() ?? "automatic")} -> ${capitalize((newChannel as VoiceChannel).rtcRegion?.toUpperCase() ?? "automatic")}`
+ [
+ (oldChannel as VoiceChannel).rtcRegion ?? "automatic",
+ (newChannel as VoiceChannel).rtcRegion ?? "automatic"
+ ],
+ `${capitalize(
+ (oldChannel as VoiceChannel).rtcRegion?.toUpperCase() ?? "automatic"
+ )} -> ${capitalize((newChannel as VoiceChannel).rtcRegion?.toUpperCase() ?? "automatic")}`
);
break;
}
@@ -183,16 +245,29 @@
newTopic = "None";
}
if ((oldChannel as StageChannel).bitrate !== (newChannel as StageChannel).bitrate)
- changes.bitrate = entry([(oldChannel as StageChannel).bitrate.toString(), (newChannel as StageChannel).bitrate.toString()], `${(oldChannel as StageChannel).bitrate} -> ${(newChannel as StageChannel).bitrate}`);
+ changes.bitrate = entry(
+ [(oldChannel as StageChannel).bitrate.toString(), (newChannel as StageChannel).bitrate.toString()],
+ `${(oldChannel as StageChannel).bitrate} -> ${(newChannel as StageChannel).bitrate}`
+ );
if ((oldChannel as StageChannel).userLimit !== (newChannel as StageChannel).userLimit)
changes.maxUsers = entry(
- [(oldChannel as StageChannel).userLimit.toString(), (newChannel as StageChannel).userLimit.toString()],
- `${(oldChannel as StageChannel).userLimit ? (oldChannel as StageChannel).userLimit : "Unlimited"} -> ${(newChannel as StageChannel).userLimit}`
+ [
+ (oldChannel as StageChannel).userLimit.toString(),
+ (newChannel as StageChannel).userLimit.toString()
+ ],
+ `${
+ (oldChannel as StageChannel).userLimit ? (oldChannel as StageChannel).userLimit : "Unlimited"
+ } -> ${(newChannel as StageChannel).userLimit}`
);
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?.toLowerCase() ?? "automatic")} -> ${capitalize((newChannel as StageChannel).rtcRegion?.toLowerCase() ?? "automatic")}`
+ [
+ (oldChannel as StageChannel).rtcRegion ?? "Automatic",
+ (newChannel as StageChannel).rtcRegion ?? "Automatic"
+ ],
+ `${capitalize(
+ (oldChannel as StageChannel).rtcRegion?.toLowerCase() ?? "automatic"
+ )} -> ${capitalize((newChannel as StageChannel).rtcRegion?.toLowerCase() ?? "automatic")}`
);
break;
}
@@ -210,8 +285,7 @@
}
const ocType = channelTypeEmoji[oldChannel.type],
ncType = channelTypeEmoji[newChannel.type];
- if (oldChannel.type !== newChannel.type)
- changes.type = entry([ocType!, ncType!], `${ocType!} -> ${readableType}`);
+ if (oldChannel.type !== newChannel.type) changes.type = entry([ocType!, ncType!], `${ocType!} -> ${readableType}`);
if (!(Object.values(changes).length - 4)) return;
const data = {
meta: {
diff --git a/src/events/commandError.ts b/src/events/commandError.ts
index ff5f4ae..e7d9bf5 100644
--- a/src/events/commandError.ts
+++ b/src/events/commandError.ts
@@ -1,16 +1,20 @@
-import type { ButtonInteraction, ContextMenuCommandInteraction } from 'discord.js';
-import type { CommandInteraction } from 'discord.js';
+import type { ButtonInteraction, ContextMenuCommandInteraction } from "discord.js";
+import type { CommandInteraction } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
export const event = "commandError";
-export async function callback(_: NucleusClient, interaction: CommandInteraction | ButtonInteraction | ContextMenuCommandInteraction, error: string) {
+export async function callback(
+ _: NucleusClient,
+ interaction: CommandInteraction | ButtonInteraction | ContextMenuCommandInteraction,
+ error: string
+) {
const embed = new EmojiEmbed()
.setTitle("Something went wrong")
.setDescription(error)
.setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
+ .setEmoji("CONTROL.BLOCKCROSS");
if (interaction.replied || interaction.deferred) {
await interaction.followUp({
embeds: [embed],
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 2630295..96f7909 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -1,13 +1,14 @@
-import { AuditLogEvent } from 'discord.js';
+import { AuditLogEvent } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
-import type { GuildEmoji, GuildAuditLogsEntry } from 'discord.js'
+import type { GuildEmoji, GuildAuditLogsEntry } from "discord.js";
export const event = "emojiCreate";
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))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0];
+ 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;
if (auditLog.executor!.id === client.user!.id) return;
const data = {
@@ -31,4 +32,3 @@
};
log(data);
}
-
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index c4b488e..52822cb 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -1,13 +1,14 @@
-import { AuditLogEvent } from 'discord.js';
+import { AuditLogEvent } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
-import type { GuildEmoji, GuildAuditLogsEntry } from 'discord.js'
+import type { GuildEmoji, GuildAuditLogsEntry } from "discord.js";
export const event = "emojiDelete";
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.EmojiDelete))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === emoji.id)[0];
+ if (!(await isLogging(emoji.guild.id, "emojiUpdate"))) return;
+ 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;
const data = {
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index 98ff558..173f5c5 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -1,14 +1,15 @@
-import { AuditLogEvent } from 'discord.js';
+import { AuditLogEvent } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
-import type { GuildEmoji, GuildAuditLogsEntry } from 'discord.js'
+import type { GuildEmoji, GuildAuditLogsEntry } from "discord.js";
export const event = "emojiUpdate";
export async function callback(client: NucleusClient, oldEmoji: GuildEmoji, newEmoji: GuildEmoji) {
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.EmojiUpdate))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildEmoji)!.id === newEmoji.id)[0];
+ 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;
@@ -16,7 +17,10 @@
emojiId: entry(newEmoji.id, `\`${newEmoji.id}\``),
emoji: entry(newEmoji.id, renderEmoji(newEmoji)),
edited: entry(newEmoji.createdTimestamp, renderDelta(newEmoji.createdTimestamp)),
- editedBy: entry(auditLog.executor!.id, renderUser((await newEmoji.guild.members.fetch(auditLog.executor!.id)).user)),
+ editedBy: entry(
+ auditLog.executor!.id,
+ renderUser((await newEmoji.guild.members.fetch(auditLog.executor!.id)).user)
+ ),
name: entry([oldEmoji.name!, newEmoji.name!], `\`:${oldEmoji.name}:\` -> \`:${newEmoji.name}:\``)
};
const data = {
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index cac4b41..93f4ec8 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -1,5 +1,5 @@
import type { GuildAuditLogsEntry, GuildBan, User } from "discord.js";
-import { AuditLogEvent } from 'discord.js';
+import { AuditLogEvent } from "discord.js";
import { purgeByUser } from "../actions/tickets/delete.js";
import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
import type { NucleusClient } from "../utils/client.js";
@@ -11,8 +11,9 @@
await statsChannelRemove(client, undefined, ban.guild, ban.user);
purgeByUser(ban.user.id, ban.guild.id);
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];
+ 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;
await client.database.history.create("ban", ban.guild.id, ban.user, auditLog.executor, auditLog.reason);
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 3be4560..fc916ba 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -6,9 +6,10 @@
export async function callback(client: NucleusClient, ban: GuildBan) {
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 (!(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;
await client.database.history.create("unban", ban.guild.id, ban.user, auditLog.executor, auditLog.reason);
diff --git a/src/events/guildDelete.ts b/src/events/guildDelete.ts
index 92af401..0a4904e 100644
--- a/src/events/guildDelete.ts
+++ b/src/events/guildDelete.ts
@@ -1,10 +1,10 @@
-import client, { NucleusClient } from '../utils/client.js'
-import type { Guild } from 'discord.js'
+import client, { NucleusClient } from "../utils/client.js";
+import type { Guild } from "discord.js";
-export const event = 'guildDelete'
+export const event = "guildDelete";
export const callback = async (_client: NucleusClient, guild: Guild) => {
await client.database.guilds.delete(guild.id);
await client.database.history.delete(guild.id);
await client.database.notes.delete(guild.id);
await client.database.transcripts.deleteAll(guild.id);
-}
\ No newline at end of file
+};
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index 721978f..a0acd34 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -7,37 +7,49 @@
export async function callback(client: NucleusClient, before: GuildMember, after: GuildMember) {
const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
- if(before.guild.id === "684492926528651336") {
- await client.database.premium.checkAllPremium(after)
+ if (before.guild.id === "684492926528651336") {
+ await client.database.premium.checkAllPremium(after);
}
- if(!before.roles.cache.equals(after.roles.cache)) {
- const auditLog = (await getAuditLog(after.guild, AuditLogEvent.MemberRoleUpdate))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === after.id)[0];
+ if (!before.roles.cache.equals(after.roles.cache)) {
+ const auditLog = (await getAuditLog(after.guild, AuditLogEvent.MemberRoleUpdate)).filter(
+ (entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === after.id
+ )[0];
if (!auditLog) return;
if (client.noLog.includes(`${after.guild.id}${after.id}${auditLog.id}`)) return;
generalException(`${after.guild.id}${after.id}${auditLog.id}`);
if (auditLog.executor!.id !== client.user!.id) {
- const rolesAdded = after.roles.cache.filter(role => !before.roles.cache.has(role.id));
- const rolesRemoved = before.roles.cache.filter(role => !after.roles.cache.has(role.id));
+ const rolesAdded = after.roles.cache.filter((role) => !before.roles.cache.has(role.id));
+ const 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";}
- const removedEntry = rolesRemoved.map(role => role.id);
- const addedEntry = rolesAdded.map(role => role.id);
+ 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";
+ }
+ const removedEntry = rolesRemoved.map((role) => role.id);
+ const addedEntry = rolesAdded.map((role) => role.id);
let list = {
memberId: entry(after.id, `\`${after.id}\``),
- name: entry(after.user.id, renderUser(after.user)),
+ name: entry(after.user.id, renderUser(after.user))
};
if (rolesAdded.size > 0) {
- list = Object.assign(list, {rolesAdded: entry(addedEntry, addedEntry.map(id => `<@&${id}>`).join(", "))});
+ 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(", "))});
+ list = Object.assign(list, {
+ rolesRemoved: entry(removedEntry, removedEntry.map((id) => `<@&${id}>`).join(", "))
+ });
}
list = Object.assign(list, {
@@ -60,18 +72,23 @@
}
};
- if(rolesAdded.size > 0) {
- list = Object.assign(list, {rolesAdded: entry(addedEntry, addedEntry.map(id => `<@&${id}>`).join(", "))});
+ 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(", "))});
+ if (rolesRemoved.size > 0) {
+ list = Object.assign(list, {
+ rolesRemoved: entry(removedEntry, removedEntry.map((id) => `<@&${id}>`).join(", "))
+ });
}
- data = Object.assign(data, {list: list});
+ data = Object.assign(data, { list: list });
log(data);
}
}
- const auditLog = (await getAuditLog(after.guild, AuditLogEvent.MemberUpdate))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === after.id)[0];
+ 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.nickname !== after.nickname) {
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index 6b25e48..dbd747f 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -7,9 +7,10 @@
export async function callback(client: NucleusClient, before: Guild, after: Guild) {
await statsChannelUpdate(client, after.members.me!);
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 (!(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;
const list: Record<string, ReturnType<typeof entry>> = {};
@@ -21,23 +22,19 @@
"Verified phone"
];
- const explicitContentFilterLevels = [
- "Disabled",
- "Members without roles",
- "All members"
- ];
+ const explicitContentFilterLevels = ["Disabled", "Members without roles", "All members"];
- const MFALevels = [
- "None",
- "Enabled"
- ];
+ const MFALevels = ["None", "Enabled"];
const beforeOwner = await before.fetchOwner();
const afterOwner = await after.fetchOwner();
if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
if (before.icon !== after.icon)
- list["icon"] = entry([before.icon!, after.icon!], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
+ list["icon"] = entry(
+ [before.icon!, after.icon!],
+ `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`
+ );
if (before.splash !== after.splash)
list["splash"] = entry(
[before.splash!, after.splash!],
@@ -55,8 +52,13 @@
);
if (before.verificationLevel !== after.verificationLevel)
list["verificationLevel"] = entry(
- [verificationLevels[before.verificationLevel.valueOf()]!, verificationLevels[before.verificationLevel.valueOf()]!],
- `${verificationLevels[before.verificationLevel.valueOf()]} -> ${verificationLevels[before.verificationLevel.valueOf()]}`
+ [
+ verificationLevels[before.verificationLevel.valueOf()]!,
+ verificationLevels[before.verificationLevel.valueOf()]!
+ ],
+ `${verificationLevels[before.verificationLevel.valueOf()]} -> ${
+ verificationLevels[before.verificationLevel.valueOf()]
+ }`
);
if (before.explicitContentFilter !== after.explicitContentFilter)
list["explicitContentFilter"] = entry(
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index 80c2c1b..c91f8cd 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -11,17 +11,30 @@
export const event = "interactionCreate";
-
async function interactionCreate(interaction: Interaction) {
if (interaction.isButton()) {
switch (interaction.customId) {
- case "rolemenu": { return await roleMenu(interaction); }
- case "verifybutton": { return await verify(interaction); }
- case "createticket": { return await create(interaction); }
- case "closeticket": { return await close(interaction); }
- case "createtranscript": { return await createTranscript(interaction); }
- case "suggestionAccept": { return await modifySuggestion(interaction, true); }
- case "suggestionDeny": { return await modifySuggestion(interaction, false); }
+ case "rolemenu": {
+ return await roleMenu(interaction);
+ }
+ case "verifybutton": {
+ return await verify(interaction);
+ }
+ case "createticket": {
+ return await create(interaction);
+ }
+ case "closeticket": {
+ return await close(interaction);
+ }
+ case "createtranscript": {
+ return await createTranscript(interaction);
+ }
+ case "suggestionAccept": {
+ return await modifySuggestion(interaction, true);
+ }
+ case "suggestionDeny": {
+ return await modifySuggestion(interaction, false);
+ }
}
}
}
@@ -32,7 +45,10 @@
if (message.embeds.length === 0) return;
const embed = message.embeds[0];
const newcolor = accept ? "Success" : "Danger";
- const footer = {text: `Suggestion ${accept ? "accepted" : "denied"} by ${interaction.user.tag}`, iconURL: interaction.user.displayAvatarURL()};
+ const footer = {
+ text: `Suggestion ${accept ? "accepted" : "denied"} by ${interaction.user.tag}`,
+ iconURL: interaction.user.displayAvatarURL()
+ };
const newEmbed = new EmojiEmbed()
.setTitle(embed!.title!)
@@ -40,7 +56,7 @@
.setFooter(footer)
.setStatus(newcolor);
- await interaction.update({embeds: [newEmbed], components: []});
+ await interaction.update({ embeds: [newEmbed], components: [] });
}
export async function callback(_client: NucleusClient, interaction: Interaction) {
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 34f66dc..240965c 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -6,11 +6,12 @@
export const event = "inviteCreate";
export async function callback(client: NucleusClient, invite: Invite) {
- if(!invite.guild) return; // This is a DM invite (not a guild invite
+ if (!invite.guild) return; // This is a DM invite (not a guild invite
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 (!(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;
const data = {
meta: {
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index 456af90..81285c7 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -6,11 +6,12 @@
export const event = "inviteDelete";
export async function callback(client: NucleusClient, invite: Invite) {
- if(!invite.guild) return; // This is a DM invite (not a guild invite
+ if (!invite.guild) return; // This is a DM invite (not a guild invite
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 (!(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;
const data = {
meta: {
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index 77b111f..bdfd999 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -9,7 +9,7 @@
welcome(client, member);
statsChannelAdd(client, member);
const { log, isLogging, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- if (!await isLogging(member.guild.id, "guildMemberUpdate")) return;
+ if (!(await isLogging(member.guild.id, "guildMemberUpdate"))) return;
await client.database.history.create("join", member.guild.id, member.user, null, null);
const data = {
meta: {
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 8b3d1b1..c4ce74e 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -11,11 +11,13 @@
purgeByUser(member.id, member.guild.id);
await statsChannelRemove(client, member);
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];
+ 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 (kickAuditLog) {
if (kickAuditLog.executor!.id === client.user!.id) return;
@@ -27,16 +29,22 @@
if (banAuditLog.executor!.id === client.user!.id) return;
if (banAuditLog.createdAt.getTime() >= startTime) {
if (!kickAuditLog) {
- return
+ return;
} else if (kickAuditLog.createdAt.valueOf() < banAuditLog.createdAt.valueOf()) {
- return
+ return;
}
}
}
let data;
if (type === "kick") {
if (!kickAuditLog) return;
- await client.database.history.create("kick", member.guild.id, member.user, kickAuditLog.executor, kickAuditLog.reason);
+ await client.database.history.create(
+ "kick",
+ member.guild.id,
+ member.user,
+ kickAuditLog.executor,
+ kickAuditLog.reason
+ );
data = {
meta: {
type: "memberKick",
@@ -52,7 +60,10 @@
joined: entry(member.joinedTimestamp, renderDelta(member.joinedTimestamp?.valueOf()!)),
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.*"),
+ 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
},
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index 14ec7e5..b106d61 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -13,10 +13,11 @@
if (!message.guild) return;
const config = await client.memory.readGuildInfo(message.guild.id);
- if (config.autoPublish.enabled
- && config.autoPublish.channels.includes(message.channel.id)
- && message.channel.type === ChannelType.GuildAnnouncement
- && message.reference === null
+ if (
+ config.autoPublish.enabled &&
+ config.autoPublish.channels.includes(message.channel.id) &&
+ message.channel.type === ChannelType.GuildAnnouncement &&
+ message.reference === null
) {
await message.crosspost();
}
@@ -34,11 +35,11 @@
const fileNames = await logAttachment(message);
const content = message.content.toLowerCase() || "";
- if(config.filters.clean.channels.includes(message.channel.id)) {
- const memberRoles = message.member!.roles.cache.map(role => role.id);
- const roleAllow = config.filters.clean.allowed.roles.some(role => memberRoles.includes(role));
+ if (config.filters.clean.channels.includes(message.channel.id)) {
+ const memberRoles = message.member!.roles.cache.map((role) => role.id);
+ const roleAllow = config.filters.clean.allowed.roles.some((role) => memberRoles.includes(role));
const userAllow = config.filters.clean.allowed.users.includes(message.author.id);
- if(!roleAllow && !userAllow) return await message.delete();
+ if (!roleAllow && !userAllow) return await message.delete();
}
const filter = getEmojiByName("ICONS.FILTER");
@@ -94,7 +95,11 @@
if (fileNames.files.length > 0) {
for (const element of fileNames.files) {
const url = element.url ? element.url : element.local;
- if (/\.(j(pe?g|fif)|a?png|gifv?|w(eb[mp]|av)|mp([34]|eg-\d)|ogg|avi|h\.26(4|5)|cda)$/.test(url.toLowerCase())) {
+ if (
+ /\.(j(pe?g|fif)|a?png|gifv?|w(eb[mp]|av)|mp([34]|eg-\d)|ogg|avi|h\.26(4|5)|cda)$/.test(
+ url.toLowerCase()
+ )
+ ) {
// jpg|jpeg|png|apng|gif|gifv|webm|webp|mp4|wav|mp3|ogg|jfif|MPEG-#|avi|h.264|h.265
if (
config.filters.images.NSFW &&
@@ -288,7 +293,7 @@
}
if (config.filters.pings.everyone && message.mentions.everyone) {
- if(!await isLogging(message.guild.id, "messageMassPing")) return;
+ if (!(await isLogging(message.guild.id, "messageMassPing"))) return;
const data = {
meta: {
type: "everyonePing",
@@ -313,7 +318,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;
+ if (!(await isLogging(message.guild.id, "messageMassPing"))) return;
const data = {
meta: {
type: "rolePing",
@@ -340,7 +345,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;
+ if (!(await isLogging(message.guild.id, "messageMassPing"))) return;
const data = {
meta: {
type: "massPing",
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index aac83f4..c29bfd0 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -8,9 +8,10 @@
if (message.author.bot) return;
if (client.noLog.includes(`${message.guild!.id}/${message.channel.id}/${message.id}`)) return;
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 (!(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 < Date.now()) return;
}
@@ -19,7 +20,8 @@
content.replace("`", "\\`");
if (content.length > 256) content = content.substring(0, 253) + "...";
const attachments =
- message.attachments.size + (
+ message.attachments.size +
+ (
message.content.match(
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi
) ?? []
@@ -28,7 +30,9 @@
const config = (await client.database.guilds.read(message.guild!.id)).logging.attachments.saved[
message.channel.id + message.id
];
- if (config) { attachmentJump = ` [[View attachments]](${config})`; }
+ if (config) {
+ attachmentJump = ` [[View attachments]](${config})`;
+ }
const data = {
meta: {
type: "messageDelete",
@@ -44,14 +48,20 @@
list: {
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)),
+ sentIn: entry(
+ message.channel.id,
+ renderChannel(message.channel as Discord.GuildChannel | Discord.ThreadChannel)
+ ),
deleted: entry(Date.now(), renderDelta(Date.now())),
mentions: message.mentions.users.size,
attachments: entry(attachments, attachments + attachmentJump),
repliedTo: entry(
replyTo ? replyTo.messageId! : null,
- replyTo ? `[[Jump to message]](https://discord.com/channels/${message.guild!.id}/${message.channel.id}/${replyTo.messageId})`
- : "None"
+ replyTo
+ ? `[[Jump to message]](https://discord.com/channels/${message.guild!.id}/${message.channel.id}/${
+ replyTo.messageId
+ })`
+ : "None"
)
},
hidden: {
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index f5a28a4..3b7f482 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -8,8 +8,9 @@
if (newMessage.author.id === client.user!.id) return;
if (newMessage.author.bot) return;
if (!newMessage.guild) return;
- const { log, isLogging, 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("`", "‘");
@@ -21,7 +22,7 @@
attachmentJump = ` [[View attachments]](${config})`;
}
if (newMessage.crosspostable !== oldMessage.crosspostable) {
- if(!await isLogging(newMessage.guild.id, "messageAnnounce")) return;
+ if (!(await isLogging(newMessage.guild.id, "messageAnnounce"))) return;
if (!replyTo) {
const data = {
meta: {
@@ -38,15 +39,12 @@
list: {
messageId: entry(newMessage.id, `\`${newMessage.id}\``),
sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
- sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel as Discord.GuildBasedChannel)),
- sent: entry(
- newMessage.createdTimestamp,
- renderDelta(newMessage.createdTimestamp)
+ sentIn: entry(
+ newMessage.channel.id,
+ renderChannel(newMessage.channel as Discord.GuildBasedChannel)
),
- published: entry(
- newMessage.editedTimestamp!,
- renderDelta(newMessage.editedTimestamp!)
- ),
+ sent: entry(newMessage.createdTimestamp, renderDelta(newMessage.createdTimestamp)),
+ published: entry(newMessage.editedTimestamp!, renderDelta(newMessage.editedTimestamp!)),
mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
attachments: entry(
renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
@@ -60,7 +58,7 @@
return log(data);
}
}
- if (!await isLogging(newMessage.guild.id, "messageUpdate")) return;
+ 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 be385f0..9b900f8 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -5,10 +5,11 @@
export async function callback(client: NucleusClient, role: Role) {
const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = client.logger;
- if (!await isLogging(role.guild.id, "guildRoleUpdate")) return;
+ 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]!;
+ const auditLog = (await getAuditLog(role.guild as Guild, AuditLogEvent.RoleCreate)).filter(
+ (entry: GuildAuditLogsEntry) => (entry.target as Role)!.id === role.id
+ )[0]!;
if (auditLog.executor!.id === client.user!.id) return;
const data = {
meta: {
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index b207f4f..e83d557 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -6,10 +6,11 @@
export async function callback(client: NucleusClient, role: Role) {
const { getAuditLog, isLogging, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- if (!await isLogging(role.guild.id, "guildRoleUpdate")) return;
+ 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]!;
+ const auditLog = (await getAuditLog(role.guild as Guild, AuditLogEvent.RoleDelete)).filter(
+ (entry: GuildAuditLogsEntry) => (entry.target as Role)!.id === role.id
+ )[0]!;
if (auditLog.executor!.id === client.user!.id) return;
const data = {
meta: {
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 8d9ef10..236bc0f 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -6,9 +6,10 @@
export async function callback(client: NucleusClient, oldRole: Role, newRole: Role) {
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 (!(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;
if (auditLog.executor!.id === client.user!.id) return;
@@ -16,22 +17,40 @@
roleId: entry(newRole.id, `\`${newRole.id}\``),
role: entry(newRole.id, renderRole(newRole)),
edited: entry(Date.now(), renderDelta(Date.now())),
- editedBy: entry(auditLog.executor!.id, renderUser((await newRole.guild.members.fetch(auditLog.executor!.id)).user))
+ editedBy: entry(
+ auditLog.executor!.id,
+ renderUser((await newRole.guild.members.fetch(auditLog.executor!.id)).user)
+ )
};
const mentionable = ["", ""];
const hoist = ["", ""];
- mentionable[0] = oldRole.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
- mentionable[1] = newRole.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ mentionable[0] = oldRole.mentionable
+ ? `${getEmojiByName("CONTROL.TICK")} Yes`
+ : `${getEmojiByName("CONTROL.CROSS")} No`;
+ mentionable[1] = newRole.mentionable
+ ? `${getEmojiByName("CONTROL.TICK")} Yes`
+ : `${getEmojiByName("CONTROL.CROSS")} No`;
hoist[0] = oldRole.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
hoist[1] = newRole.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
- if (oldRole.name !== newRole.name) changes["name"] = entry([oldRole.name, newRole.name], `${oldRole.name} -> ${newRole.name}`);
+ if (oldRole.name !== newRole.name)
+ changes["name"] = entry([oldRole.name, newRole.name], `${oldRole.name} -> ${newRole.name}`);
if (oldRole.position !== newRole.position)
- changes["position"] = entry([oldRole.position.toString(), newRole.position.toString()], `${oldRole.position} -> ${newRole.position}`);
- if (oldRole.hoist !== newRole.hoist) changes["showInMemberList"] = entry([oldRole.hoist, newRole.hoist], `${hoist[0]} -> ${hoist[1]}`);
+ changes["position"] = entry(
+ [oldRole.position.toString(), newRole.position.toString()],
+ `${oldRole.position} -> ${newRole.position}`
+ );
+ if (oldRole.hoist !== newRole.hoist)
+ changes["showInMemberList"] = entry([oldRole.hoist, newRole.hoist], `${hoist[0]} -> ${hoist[1]}`);
if (oldRole.mentionable !== newRole.mentionable)
- changes["mentionable"] = entry([oldRole.mentionable, newRole.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
+ changes["mentionable"] = entry(
+ [oldRole.mentionable, newRole.mentionable],
+ `${mentionable[0]} -> ${mentionable[1]}`
+ );
if (oldRole.hexColor !== newRole.hexColor)
- changes["color"] = entry([oldRole.hexColor, newRole.hexColor], `\`${oldRole.hexColor}\` -> \`${newRole.hexColor}\``);
+ changes["color"] = entry(
+ [oldRole.hexColor, newRole.hexColor],
+ `\`${oldRole.hexColor}\` -> \`${newRole.hexColor}\``
+ );
if (oldRole.permissions.bitfield !== newRole.permissions.bitfield) {
changes["permissions"] = entry(
[oldRole.permissions.bitfield.toString(), newRole.permissions.bitfield.toString()],
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index 5d2e443..01944fc 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -6,9 +6,10 @@
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.StickerCreate))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!;
+ if (!(await isLogging(sticker.guild!.id, "stickerUpdate"))) return;
+ 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;
if (client.noLog.includes(`${sticker.guild!.id}${auditLog.id}`)) return;
generalException(`${sticker.guild!.id}${auditLog.id}`);
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index d123f44..a348b73 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -5,9 +5,10 @@
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.StickerDelete))
- .filter((entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === sticker.id)[0]!;
+ 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;
const data = {
meta: {
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index aef28a4..c42f775 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -5,16 +5,20 @@
export async function callback(client: NucleusClient, oldSticker: Sticker, newSticker: Sticker) {
const { getAuditLog, isLogging, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
- if (!await isLogging(newSticker.guild!.id, "stickerUpdate")) return;
+ 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]!;
+ const auditLog = (await getAuditLog(newSticker.guild!, AuditLogEvent.StickerUpdate)).filter(
+ (entry: GuildAuditLogsEntry) => (entry.target as Sticker)!.id === newSticker.id
+ )[0]!;
if (auditLog.executor!.id === client.user!.id) return;
const changes = {
stickerId: entry(newSticker.id, `\`${newSticker.id}\``),
edited: entry(newSticker.createdTimestamp, renderDelta(newSticker.createdTimestamp)),
- editedBy: entry(auditLog.executor!.id, renderUser((await newSticker.guild!.members.fetch(auditLog.executor!.id)).user)),
+ editedBy: entry(
+ auditLog.executor!.id,
+ renderUser((await newSticker.guild!.members.fetch(auditLog.executor!.id)).user)
+ ),
name: entry([oldSticker.name, newSticker.name], `\`:${oldSticker.name}:\` -> \`:${newSticker.name}:\``)
};
const data = {
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index f56e1bb..cefaf3b 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -6,9 +6,10 @@
export async function callback(client: NucleusClient, thread: ThreadChannel) {
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 (!(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;
const category = thread.parent
? entry(
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index bfac75e..ecbf4cf 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -6,9 +6,10 @@
export async function callback(client: NucleusClient, thread: ThreadChannel) {
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 (!(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;
const category = thread.parent
? entry(
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index af792bc..510ec30 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -7,9 +7,10 @@
export async function callback(client: NucleusClient, oldThread: ThreadChannel, newThread: ThreadChannel) {
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 (!(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;
const list: Record<string, ReturnType<typeof entry>> = {
threadId: entry(newThread.id, `\`${newThread.id}\``),
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index 004f754..438c66e 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -10,14 +10,21 @@
export async function callback(client: NucleusClient, channel: Discord.GuildChannel) {
try {
- 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 | null) => (entry?.target) ? (entry.target as Webhook)!.channelId === channel.id : false)[0];
- const auditDelete = (await getAuditLog(channel.guild, AuditLogEvent.WebhookDelete, 0))
- .filter((entry: GuildAuditLogsEntry | null) => (entry?.target) ? (entry.target as Webhook)!.channelId === channel.id : false)[0];
- const auditUpdate = (await getAuditLog(channel.guild, AuditLogEvent.WebhookUpdate, 0))
- .filter((entry: GuildAuditLogsEntry | null) => (entry?.target) ? (entry.target as Webhook)!.channelId === channel.id : false)[0];
+ 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 | null) =>
+ entry?.target ? (entry.target as Webhook)!.channelId === channel.id : false
+ )[0];
+ const auditDelete = (await getAuditLog(channel.guild, AuditLogEvent.WebhookDelete, 0)).filter(
+ (entry: GuildAuditLogsEntry | null) =>
+ entry?.target ? (entry.target as Webhook)!.channelId === channel.id : false
+ )[0];
+ const auditUpdate = (await getAuditLog(channel.guild, AuditLogEvent.WebhookUpdate, 0)).filter(
+ (entry: GuildAuditLogsEntry | null) =>
+ entry?.target ? (entry.target as Webhook)!.channelId === channel.id : false
+ )[0];
if (!auditCreate && !auditUpdate && !auditDelete) return;
let action: "Create" | "Update" | "Delete" = "Create";
let list: Record<string, ReturnType<typeof entry> | string> = {};
@@ -25,7 +32,8 @@
const deleteTimestamp = auditDelete ? auditDelete.createdTimestamp : 0;
const updateTimestamp = auditUpdate ? auditUpdate.createdTimestamp : 0;
if (updateTimestamp > createTimestamp && updateTimestamp > deleteTimestamp && auditUpdate) {
- const { before, after } = auditUpdate.changes.reduce((acc: accType, change) => {
+ const { before, after } = auditUpdate.changes.reduce(
+ (acc: accType, change) => {
acc.before[change.key] = change.old?.toString()!;
acc.after[change.key] = change.new?.toString()!;
return acc;
@@ -37,20 +45,23 @@
if (before["channel_id"] !== after["channel_id"])
list["channel"] = entry(
[before["channel_id"]!, after["channel_id"]!],
- renderChannel(await client.channels.fetch(before["channel_id"]!) as GuildChannel) +
+ renderChannel((await client.channels.fetch(before["channel_id"]!)) as GuildChannel) +
" -> " +
- renderChannel(await client.channels.fetch(after["channel_id"]!) as GuildChannel)
+ renderChannel((await client.channels.fetch(after["channel_id"]!)) as GuildChannel)
);
if (!Object.keys(list).length) return;
list["created"] = entry(
- (auditUpdate.target! as Extract<GuildAuditLogsEntry, {createdTimestamp: number}>).createdTimestamp,
- renderDelta((auditUpdate.target! as Extract<GuildAuditLogsEntry, {createdTimestamp: number}>).createdTimestamp)
+ (auditUpdate.target! as Extract<GuildAuditLogsEntry, { createdTimestamp: number }>).createdTimestamp,
+ renderDelta(
+ (auditUpdate.target! as Extract<GuildAuditLogsEntry, { createdTimestamp: number }>).createdTimestamp
+ )
);
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) {
- const { before } = auditDelete.changes.reduce((acc: accType, change) => {
+ const { before } = auditDelete.changes.reduce(
+ (acc: accType, change) => {
acc.before[change.key] = change.old?.toString()!;
acc.after[change.key] = change.new?.toString()!;
return acc;
@@ -59,8 +70,18 @@
);
list = {
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)),
+ 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(Date.now(), renderDelta(Date.now())),
deletedBy: entry(
auditDelete.executor!.id,
@@ -69,7 +90,8 @@
};
action = "Delete";
} else {
- const { before } = auditDelete!.changes.reduce((acc: accType, change) => {
+ const { before } = auditDelete!.changes.reduce(
+ (acc: accType, change) => {
acc.before[change.key] = change.old?.toString()!;
acc.after[change.key] = change.new?.toString()!;
return acc;
@@ -78,7 +100,10 @@
);
list = {
name: entry(before["name"]!, `${before["name"]}`),
- channel: entry(before["channel_id"]!, renderChannel(await client.channels.fetch(before["channel_id"]!) as GuildChannel)),
+ channel: entry(
+ before["channel_id"]!,
+ renderChannel((await client.channels.fetch(before["channel_id"]!)) as GuildChannel)
+ ),
createdBy: entry(
auditCreate!.executor!.id,
renderUser((await channel.guild.members.fetch(auditCreate!.executor!.id)).user)