From c0bc2163f57936abc3e1e740d2e1ce5353eb03ca Mon Sep 17 00:00:00 2001 From: rladenson Date: Wed, 20 Nov 2024 16:28:42 -0700 Subject: [PATCH] fix: allow servernameformat to be run in DMs --- PluralKit.Bot/Commands/Config.cs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/PluralKit.Bot/Commands/Config.cs b/PluralKit.Bot/Commands/Config.cs index cedc6c66..a6783fb7 100644 --- a/PluralKit.Bot/Commands/Config.cs +++ b/PluralKit.Bot/Commands/Config.cs @@ -137,12 +137,24 @@ public class Config ProxyMember.DefaultFormat )); - items.Add(new( - "Server Name Format", - "Format string used to display a member's name in the current server", - (await ctx.Repository.GetSystemGuild(ctx.Guild.Id, ctx.System.Id)).NameFormat ?? "none set", - "none set" - )); + if (ctx.Guild == null) + { + items.Add(new( + "Server Name Format", + "Format string used to display a member's name in the current server", + "only available in servers", + "only available in servers" + )); + } + else + { + items.Add(new( + "Server Name Format", + "Format string used to display a member's name in the current server", + (await ctx.Repository.GetSystemGuild(ctx.Guild.Id, ctx.System.Id)).NameFormat ?? "none set", + "none set" + )); + } await ctx.Paginate( items.ToAsyncEnumerable(), @@ -593,6 +605,7 @@ public class Config public async Task ServerNameFormat(Context ctx) { + ctx.CheckGuildContext(); var clearFlag = ctx.MatchClear(); var format = ctx.MatchFormat();