Add permission check

This commit is contained in:
Nuckyz 2025-01-27 23:17:12 -03:00
parent 9ddeb2c67d
commit d06789d963
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -12,7 +12,7 @@ import { Devs } from "@utils/constants";
import { classes } from "@utils/misc";
import definePlugin from "@utils/types";
import { findByCodeLazy } from "@webpack";
import { useEffect } from "@webpack/common";
import { GuildStore, PermissionsBits, PermissionStore, useEffect } from "@webpack/common";
import { PropsWithChildren } from "react";
const cl = classNameFactory("vc-discord-fixes-");
@ -36,6 +36,10 @@ function setMemberSupplementalCache(cache: MemberSupplementalCache) {
function useFetchMemberSupplemental(guildId: string, userId: string) {
useEffect(() => {
if (!PermissionStore.can(PermissionsBits.MANAGE_GUILD, GuildStore.getGuild(guildId))) {
return;
}
// Set this member as unfetched in the member supplemental cache
memberSupplementalCache[`${guildId}-${userId}`] ??= 1;
fetchMemberSupplemental(guildId, [userId]);