Load Discord SDK on demand when DiscordActivity mounts
cgen-96d84a8d79a14298866686924b6c4043
This commit is contained in:
parent
bb732847f7
commit
b829a50cc7
1 changed files with 7 additions and 1 deletions
|
|
@ -20,7 +20,13 @@ export default function DiscordActivity() {
|
|||
useEffect(() => {
|
||||
const initDiscordSDK = async () => {
|
||||
try {
|
||||
// Discord SDK should be loaded by the script in index.html
|
||||
// Load Discord SDK on demand
|
||||
const loadDiscordSDK = (window as any).loadDiscordSDK;
|
||||
if (loadDiscordSDK) {
|
||||
await loadDiscordSDK();
|
||||
}
|
||||
|
||||
// Discord SDK should now be loaded
|
||||
if (!(window as any).DiscordSDK) {
|
||||
throw new Error("Discord SDK not loaded");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue