MCPcopy Create free account
hub / github.com/Botloader/botloader / FullGuildProvider

Function FullGuildProvider

frontend/src/modules/guilds/FullGuildProvider.tsx:15–37  ·  view source on GitHub ↗
({ children, guildId }: { guildId?: string, children: React.ReactNode })

Source from the content-addressed store, hash-verified

13type FullGuildHook = FetchDataHookNotBehindGuard<FullGuild>
14
15export function FullGuildProvider({ children, guildId }: { guildId?: string, children: React.ReactNode }) {
16 const session = useSession()
17
18 const fetch = useCallback(async () => {
19 if (!guildId) {
20 throw new Error("guildId not set")
21 }
22
23 return await session.apiClient.getFullDiscordGuild(guildId);
24 }, [session, guildId])
25
26 if (!guildId || !session.user) {
27 return <>{children}</>
28 }
29
30 return <FetchData
31 context={fullGuildContext}
32 loader={fetch}
33 debugName="full_guild"
34 >
35 {children}
36 </FetchData>
37}
38
39export function useCurrentFullGuild(): FullGuildHook {
40 const fetchedData = useFetchedData(fullGuildContext)

Callers

nothing calls this directly

Calls 2

useSessionFunction · 0.90
getFullDiscordGuildMethod · 0.80

Tested by

no test coverage detected