From 998ce72f3b624132a439b2399828df9d9f636080 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 14 Oct 2023 02:38:57 +0200 Subject: [PATCH] ForceOwnerCrown: Remove log spam --- src/plugins/forceOwnerCrown/index.ts | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/plugins/forceOwnerCrown/index.ts b/src/plugins/forceOwnerCrown/index.ts index 5fa63f00..eaee6284 100644 --- a/src/plugins/forceOwnerCrown/index.ts +++ b/src/plugins/forceOwnerCrown/index.ts @@ -19,6 +19,7 @@ import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { GuildStore } from "@webpack/common"; +import { Channel, User } from "discord-types/general"; export default definePlugin({ name: "ForceOwnerCrown", @@ -34,25 +35,15 @@ export default definePlugin({ } } ], - isGuildOwner(props) { - // Check if channel is a Group DM, if so return false - if (props?.channel?.type === 3) { + isGuildOwner(props: { user: User, channel: Channel, guildId?: string; }) { + if (!props?.user?.id) return false; + if (props.channel?.type === 3 /* GROUP_DM */) return false; - } // guild id is in props twice, fallback if the first is undefined - const guildId = props?.guildId ?? props?.channel?.guild_id; - const userId = props?.user?.id; + const guildId = props.guildId ?? props.channel?.guild_id; + const userId = props.user.id; - if (guildId && userId) { - const guild = GuildStore.getGuild(guildId); - if (guild) { - return guild.ownerId === userId; - } - console.error("[ForceOwnerCrown] failed to get guild", { guildId, guild, props }); - } else { - console.error("[ForceOwnerCrown] no guildId or userId", { guildId, userId, props }); - } - return false; + return GuildStore.getGuild(guildId)?.ownerId === userId; }, });