fixed events/* (not including webhookUpdate.ts)
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index eefab4b..8690af2 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,66 +1,67 @@
import type { NucleusClient } from "../utils/client.js";
-import type { Guild, GuildAuditLogsEntry } from "discord.js";
+import { AuditLogEvent, Guild, GuildAuditLogsEntry } from "discord.js";
import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
export const event = "guildUpdate";
export async function callback(client: NucleusClient, before: Guild, after: Guild) {
- await statsChannelUpdate(client, after.me!);
+ await statsChannelUpdate(client, after.members.me!);
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- const auditLog = await getAuditLog(after, "GUILD_UPDATE");
- const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === after.id).first();
- if (audit.executor.id === client.user.id) 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>> = {};
- const verificationLevels = {
- NONE: "Unrestricted",
- LOW: "Verified email",
- MEDIUM: "Registered (5 minutes)",
- HIGH: "Member (10 minutes)",
- VERY_HIGH: "Verified phone"
- };
+ const verificationLevels = [
+ "Unrestricted",
+ "Verified email",
+ "Registered (5 minutes)",
+ "Member (10 minutes)",
+ "Verified phone"
+ ];
- const explicitContentFilterLevels = {
- DISABLED: "Disabled",
- MEMBERS_WITHOUT_ROLES: "Members without roles",
- ALL_MEMBERS: "All members"
- };
+ const explicitContentFilterLevels = [
+ "Disabled",
+ "Members without roles",
+ "All members"
+ ];
- const MFALevels = {
- NONE: "None",
- ELEVATED: "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],
+ [before.splash!, after.splash!],
`[Before](${before.splashURL()}) -> [After](${after.splashURL()})`
);
if (before.banner !== after.banner)
list["banner"] = entry(
- [before.banner, after.banner],
+ [before.banner!, after.banner!],
`[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`
);
if (beforeOwner !== afterOwner)
list["owner"] = entry(
- [beforeOwner, afterOwner],
+ [beforeOwner.id, afterOwner.id],
`${renderUser(beforeOwner.user)} -> ${renderUser(afterOwner.user)}`
);
if (before.verificationLevel !== after.verificationLevel)
list["verificationLevel"] = entry(
- [verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]],
- `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`
+ [verificationLevels[before.verificationLevel.valueOf()]!, verificationLevels[before.verificationLevel.valueOf()]!],
+ `${verificationLevels[before.verificationLevel.valueOf()]} -> ${verificationLevels[before.verificationLevel.valueOf()]}`
);
if (before.explicitContentFilter !== after.explicitContentFilter)
list["explicitContentFilter"] = entry(
[
- explicitContentFilterLevels[before.explicitContentFilter],
- explicitContentFilterLevels[after.explicitContentFilter]
+ explicitContentFilterLevels[before.explicitContentFilter.valueOf()]!,
+ explicitContentFilterLevels[after.explicitContentFilter.valueOf()]!
],
`${explicitContentFilterLevels[before.explicitContentFilter]} -> ${
explicitContentFilterLevels[after.explicitContentFilter]
@@ -68,13 +69,13 @@
);
if (before.mfaLevel !== after.mfaLevel)
list["2 factor authentication"] = entry(
- [MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]],
- `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`
+ [MFALevels[before.mfaLevel.valueOf()]!, MFALevels[after.mfaLevel.valueOf()]!],
+ `${MFALevels[before.mfaLevel.valueOf()]} -> ${MFALevels[after.mfaLevel.valueOf()]}`
);
if (!Object.keys(list).length) return;
list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
- list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor));
+ list["updatedBy"] = entry(auditLog.executor!.id, renderUser(auditLog.executor!));
const data = {
meta: {
type: "guildUpdate",