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; }, });