@@ -316,6 +316,25 @@ private async Task<IEnumerable<ContextCheckAttribute>> CheckPermissionsAsync(Com
316
316
var contextChecks = cmd . Attributes . Where ( x => x is ContextCheckAttribute ) ;
317
317
var failedChecks = new List < ContextCheckAttribute > ( ) ;
318
318
319
+ // similar to home server perm check logic
320
+ DiscordMember member = null ;
321
+ if ( ctx . Channel . IsPrivate || ctx . Guild . Id != Program . cfgjson . ServerID )
322
+ {
323
+ var guild = await ctx . Client . GetGuildAsync ( Program . cfgjson . ServerID ) ;
324
+ try
325
+ {
326
+ member = await guild . GetMemberAsync ( ctx . User . Id ) ;
327
+ }
328
+ catch ( DSharpPlus . Exceptions . NotFoundException )
329
+ {
330
+ // member is null, remember this for later
331
+ }
332
+ }
333
+ else
334
+ {
335
+ member = ctx . Member ;
336
+ }
337
+
319
338
foreach ( var check in contextChecks )
320
339
{
321
340
if ( check is HomeServerAttribute homeServerAttribute )
@@ -329,13 +348,13 @@ private async Task<IEnumerable<ContextCheckAttribute>> CheckPermissionsAsync(Com
329
348
if ( check is RequireHomeserverPermAttribute requireHomeserverPermAttribute )
330
349
{
331
350
// Fail if guild member is null but this cmd does not work outside of the home server
332
- if ( ctx . Member is null && ! requireHomeserverPermAttribute . WorkOutside )
351
+ if ( member is null && ! requireHomeserverPermAttribute . WorkOutside )
333
352
{
334
353
failedChecks . Add ( requireHomeserverPermAttribute ) ;
335
354
}
336
355
else
337
356
{
338
- var level = await GetPermLevelAsync ( ctx . Member ) ;
357
+ var level = await GetPermLevelAsync ( member ) ;
339
358
if ( level < requireHomeserverPermAttribute . TargetLvl )
340
359
{
341
360
if ( requireHomeserverPermAttribute . OwnerOverride && ! Program . cfgjson . BotOwners . Contains ( ctx . User . Id )
@@ -349,7 +368,7 @@ private async Task<IEnumerable<ContextCheckAttribute>> CheckPermissionsAsync(Com
349
368
350
369
if ( check is RequirePermissionsAttribute requirePermissionsAttribute )
351
370
{
352
- if ( ctx . Member is null || ctx . Guild is null
371
+ if ( member is null || ctx . Guild is null
353
372
|| ! ctx . Channel . PermissionsFor ( ctx . Member ) . HasAllPermissions ( requirePermissionsAttribute . UserPermissions )
354
373
|| ! ctx . Channel . PermissionsFor ( ctx . Guild . CurrentMember ) . HasAllPermissions ( requirePermissionsAttribute . BotPermissions ) )
355
374
{
0 commit comments