fix: don't crash in autoproxy status if targeted member was deleted (again)

This commit is contained in:
spiral 2022-03-30 05:06:47 -04:00
parent a23108f24b
commit 233d0341a2
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -97,8 +97,6 @@ public class Autoproxy
_ => null
};
Console.WriteLine(settings.AutoproxyMode);
switch (settings.AutoproxyMode)
{
case AutoproxyMode.Off:
@ -119,10 +117,15 @@ public class Autoproxy
break;
}
// AutoproxyMember is never null if Mode is Member, this is just to make the compiler shut up
case AutoproxyMode.Member when relevantMember != null:
case AutoproxyMode.Member:
{
if (relevantMember == null)
// just pretend autoproxy is off if the member was deleted
// ideally we would set it to off in the database though...
eb.Description($"Autoproxy is currently **off** in this server. To enable it, use one of the following commands:\n{commandList}");
else
eb.Description($"Autoproxy is active for member **{relevantMember.NameFor(ctx)}** (`{relevantMember.Hid}`) in this server. To disable, type `pk;autoproxy off`.");
break;
}
case AutoproxyMode.Latch: