fix(bot): correctly check for existence of current system in embeds
Some checks are pending
Build and push Docker image / .net docker build (push) Waiting to run
.net checks / run .net tests (push) Waiting to run
.net checks / dotnet-format (push) Waiting to run

This commit is contained in:
alyssa 2025-09-18 23:32:00 +00:00
parent 9c99a0bc02
commit 24361d9d2b

View file

@ -57,7 +57,7 @@ public class EmbedService
var countctx = LookupContext.ByNonOwner; var countctx = LookupContext.ByNonOwner;
if (cctx.MatchFlag("a", "all")) if (cctx.MatchFlag("a", "all"))
{ {
if (system.Id == cctx.System.Id) if (system.Id == cctx.System?.Id)
countctx = LookupContext.ByOwner; countctx = LookupContext.ByOwner;
else else
throw Errors.LookupNotAllowed; throw Errors.LookupNotAllowed;
@ -89,7 +89,7 @@ public class EmbedService
if (system.MemberListPrivacy.CanAccess(ctx)) if (system.MemberListPrivacy.CanAccess(ctx))
{ {
headerText += $"\n**Members:** {memberCount}"; headerText += $"\n**Members:** {memberCount}";
if (system.Id == cctx.System.Id) if (system.Id == cctx.System?.Id)
if (memberCount > 0) if (memberCount > 0)
headerText += $" (see `{cctx.DefaultPrefix}system list`)"; headerText += $" (see `{cctx.DefaultPrefix}system list`)";
else else
@ -215,7 +215,7 @@ public class EmbedService
var countctx = LookupContext.ByNonOwner; var countctx = LookupContext.ByNonOwner;
if (cctx.MatchFlag("a", "all")) if (cctx.MatchFlag("a", "all"))
{ {
if (system.Id == cctx.System.Id) if (system.Id == cctx.System?.Id)
countctx = LookupContext.ByOwner; countctx = LookupContext.ByOwner;
else else
throw Errors.LookupNotAllowed; throw Errors.LookupNotAllowed;
@ -570,7 +570,7 @@ public class EmbedService
var countctx = LookupContext.ByNonOwner; var countctx = LookupContext.ByNonOwner;
if (ctx.MatchFlag("a", "all")) if (ctx.MatchFlag("a", "all"))
{ {
if (system.Id == ctx.System.Id) if (system.Id == ctx.System?.Id)
countctx = LookupContext.ByOwner; countctx = LookupContext.ByOwner;
else else
throw Errors.LookupNotAllowed; throw Errors.LookupNotAllowed;
@ -588,7 +588,7 @@ public class EmbedService
if (target.ListPrivacy.CanAccess(pctx)) if (target.ListPrivacy.CanAccess(pctx))
{ {
headerText += $"\n**Members:** {memberCount}"; headerText += $"\n**Members:** {memberCount}";
if (system.Id == ctx.System.Id && memberCount == 0) if (system.Id == ctx.System?.Id && memberCount == 0)
headerText += $" (add one with `{ctx.DefaultPrefix}group {target.Reference(ctx)} add <member>`!)"; headerText += $" (add one with `{ctx.DefaultPrefix}group {target.Reference(ctx)} add <member>`!)";
else if (memberCount > 0) else if (memberCount > 0)
headerText += $" (see `{ctx.DefaultPrefix}group {target.Reference(ctx)} list`)"; headerText += $" (see `{ctx.DefaultPrefix}group {target.Reference(ctx)} list`)";
@ -680,7 +680,7 @@ public class EmbedService
var countctx = LookupContext.ByNonOwner; var countctx = LookupContext.ByNonOwner;
if (ctx.MatchFlag("a", "all")) if (ctx.MatchFlag("a", "all"))
{ {
if (system.Id == ctx.System.Id) if (system.Id == ctx.System?.Id)
countctx = LookupContext.ByOwner; countctx = LookupContext.ByOwner;
else else
throw Errors.LookupNotAllowed; throw Errors.LookupNotAllowed;