28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
// Metro module 8320 (f8321).
|
|
import _slicedToArray from "../../_bundle/_slicedToArray";
|
|
import GuildChannelStore, { GUILD_VOCAL_CHANNELS_KEY } from "../../stores/GuildChannelStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import PermissionStore from "../../stores/PermissionStore";
|
|
import { Permissions } from "../../Constants";
|
|
import { useStateFromStores } from "../../_bundle/Module589";
|
|
import { attachChannelPermissions } from "../permissions/useManageResourcePermissions";
|
|
export default function useCanCreateAnEvent(a0, a1) {
|
|
return useStateFromStores([GuildStore, GuildChannelStore, PermissionStore], () => {
|
|
const guild = GuildStore.getGuild(a0);
|
|
if (!PermissionStore.can(Permissions.ADMINISTRATOR, guild) && !PermissionStore.can(Permissions.CREATE_EVENTS, guild)) {
|
|
for (const item of GuildChannelStore.getChannels(a0)[GUILD_VOCAL_CHANNELS_KEY]) {
|
|
const channel = item.channel;
|
|
if (a1 != null && channel.type !== a1) {
|
|
continue;
|
|
}
|
|
if (!PermissionStore.can(_slicedToArray(attachChannelPermissions(channel), 1)[0], channel)) {
|
|
continue;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}, [a0, a1]);
|
|
};
|