Merge branch 'dev' into feat/usercss

This commit is contained in:
Lewis Crichton 2023-10-16 21:21:44 +01:00 committed by GitHub
commit b7cdb96e09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { GuildStore } from "@webpack/common"; import { GuildStore } from "@webpack/common";
import { Channel, User } from "discord-types/general";
export default definePlugin({ export default definePlugin({
name: "ForceOwnerCrown", name: "ForceOwnerCrown",
@ -34,25 +35,15 @@ export default definePlugin({
} }
} }
], ],
isGuildOwner(props) { isGuildOwner(props: { user: User, channel: Channel, guildId?: string; }) {
// Check if channel is a Group DM, if so return false if (!props?.user?.id) return false;
if (props?.channel?.type === 3) { if (props.channel?.type === 3 /* GROUP_DM */)
return false; return false;
}
// guild id is in props twice, fallback if the first is undefined // guild id is in props twice, fallback if the first is undefined
const guildId = props?.guildId ?? props?.channel?.guild_id; const guildId = props.guildId ?? props.channel?.guild_id;
const userId = props?.user?.id; const userId = props.user.id;
if (guildId && userId) { return GuildStore.getGuild(guildId)?.ownerId === 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;
}, },
}); });