Files
discord-decomp/modules/soundboard/canChannelUseSoundboard.tsx
T
2026-11-01 12:12:55 +02:00

49 lines
1.7 KiB
TypeScript

// Metro module 10783 (f10784).
import ChannelStore from "../../stores/ChannelStore";
import PermissionStore from "../../stores/PermissionStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import { ChannelTypesSets, Permissions } from "../../Constants";
import { useStateFromStores } from "../../_bundle/Module589";
export default function canChannelUseSoundboard(a0) {
if (a0 == null) {
return false;
}
if (ChannelTypesSets.CALLABLE.has(a0.type)) {
return true;
}
const r12 = PermissionStore.can(Permissions.USE_SOUNDBOARD, a0);
const r15 = PermissionStore.can(Permissions.SPEAK, a0);
return a0.isGuildVoiceOrThread() && r12 && r15;
};
export function canSelectedVoiceChannelUseSoundboard() {
const channel = ChannelStore.getChannel(SelectedChannelStore.getVoiceChannelId());
const r9 = channel == null;
let r10 = false;
if (!r9) {
const r14 = ChannelTypesSets.CALLABLE.has(channel.type);
r10 = true;
if (!r14) {
const r19 = PermissionStore.can(Permissions.USE_SOUNDBOARD, channel);
const r22 = PermissionStore.can(Permissions.SPEAK, channel);
r10 = channel.isGuildVoiceOrThread() && r19 && r22;
}
}
return r10;
}
export function useCanChannelUseSoundboard(a0) {
return useStateFromStores([PermissionStore], () => {
const r7 = a0 == null;
let r8 = false;
if (!r7) {
const r10 = ChannelTypesSets.CALLABLE.has(a0.type);
r8 = true;
if (!r10) {
const r15 = PermissionStore.can(Permissions.USE_SOUNDBOARD, a0);
const r18 = PermissionStore.can(Permissions.SPEAK, a0);
r8 = a0.isGuildVoiceOrThread() && r15 && r18;
}
}
return r8;
}, [a0]);
}