File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
sdk-playground/packages/client/src/pages Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,26 @@ import React from 'react';
2
2
import discordSdk from '../discordSdk' ;
3
3
import { RPCErrorCodes , Permissions , PermissionUtils } from '@discord/embedded-app-sdk' ;
4
4
5
+ function isContextlessInstance ( instanceId : string ) : boolean {
6
+ return instanceId . includes ( '-cl-' ) ;
7
+ }
8
+
5
9
export default function OpenInviteDialog ( ) {
6
10
const [ message , setMessage ] = React . useState < string > ( 'Checking for permissions...' ) ;
7
11
8
12
const [ hasPermissionToInvite , setHasPermissionToInvite ] = React . useState < boolean > ( false ) ;
9
13
10
14
React . useEffect ( ( ) => {
11
15
const calculatePermissions = async ( ) => {
12
- const { permissions} = await discordSdk . commands . getChannelPermissions ( ) ;
13
- const canInvite = PermissionUtils . can ( Permissions . CREATE_INSTANT_INVITE , permissions ) ;
16
+ let canInvite = false ;
17
+ if ( isContextlessInstance ( discordSdk . instanceId ) ) {
18
+ canInvite = true ; // contextless means no rules B^)
19
+ } else {
20
+ const { permissions} = await discordSdk . commands . getChannelPermissions ( ) ;
21
+ canInvite = PermissionUtils . can ( Permissions . CREATE_INSTANT_INVITE , permissions ) ;
22
+ }
14
23
setHasPermissionToInvite ( canInvite ) ;
24
+
15
25
if ( canInvite ) {
16
26
setMessage ( "Invite Dialog hasn't been opened... yet!" ) ;
17
27
} else {
You can’t perform that action at this time.
0 commit comments