Much more typing
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index a165770..ea9008d 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,14 +1,17 @@
+// @ts-expect-error
+import type { HaikuClient } from "jshaiku";
+import type { Guild, GuildAuditLogsEntry } from 'discord.js';
import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
export const event = "guildUpdate";
-export async function callback(client, before, after) {
- await statsChannelUpdate(client, after.me);
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger;
+export async function callback(client: HaikuClient, before: Guild, after: Guild) {
+ await statsChannelUpdate(client, after.me!);
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
const auditLog = await getAuditLog(after, "GUILD_UPDATE");
- const audit = auditLog.entries.filter((entry) => entry.target.id === after.id).first();
+ const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === after.id).first();
if (audit.executor.id === client.user.id) return;
- const list = {};
+ const list: Record<string, ReturnType<typeof entry>> = {};
const verificationLevels = {
NONE: "Unrestricted",
@@ -28,32 +31,34 @@
NONE: "None",
ELEVATED: "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.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(
+ list["splash"] = entry(
[before.splash, after.splash],
`[Before](${before.splashURL()}) -> [After](${after.splashURL()})`
);
if (before.banner !== after.banner)
- list.banner = entry(
+ list["banner"] = entry(
[before.banner, after.banner],
`[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`
);
- if (before.owner !== after.owner)
- list.owner = entry(
- [before.owner, after.owner],
- `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`
+ if (beforeOwner !== afterOwner)
+ list["owner"] = entry(
+ [beforeOwner, afterOwner],
+ `${renderUser(beforeOwner.user)} -> ${renderUser(afterOwner.user)}`
);
if (before.verificationLevel !== after.verificationLevel)
- list.verificationLevel = entry(
+ list["verificationLevel"] = entry(
[verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]],
`${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`
);
if (before.explicitContentFilter !== after.explicitContentFilter)
- list.explicitContentFilter = entry(
+ list["explicitContentFilter"] = entry(
[
explicitContentFilterLevels[before.explicitContentFilter],
explicitContentFilterLevels[after.explicitContentFilter]
@@ -69,8 +74,8 @@
);
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["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+ list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor));
const data = {
meta: {
type: "guildUpdate",