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';
22import discordSdk from '../discordSdk' ;
33import { RPCErrorCodes , Permissions , PermissionUtils } from '@discord/embedded-app-sdk' ;
44
5+ function isContextlessInstance ( instanceId : string ) : boolean {
6+ return instanceId . includes ( '-cl-' ) ;
7+ }
8+
59export default function OpenInviteDialog ( ) {
610 const [ message , setMessage ] = React . useState < string > ( 'Checking for permissions...' ) ;
711
812 const [ hasPermissionToInvite , setHasPermissionToInvite ] = React . useState < boolean > ( false ) ;
913
1014 React . useEffect ( ( ) => {
1115 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+ }
1423 setHasPermissionToInvite ( canInvite ) ;
24+
1525 if ( canInvite ) {
1626 setMessage ( "Invite Dialog hasn't been opened... yet!" ) ;
1727 } else {
You can’t perform that action at this time.
0 commit comments