From 47fcfeca0fb0ffcdb14f30860e84fe805963289d Mon Sep 17 00:00:00 2001 From: acw0 Date: Sat, 25 Jul 2020 07:25:10 -0400 Subject: [PATCH] Consolidate conditionals --- PluralKit.Bot/Commands/Misc.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/PluralKit.Bot/Commands/Misc.cs b/PluralKit.Bot/Commands/Misc.cs index f95bb1d7..8b9c4bd8 100644 --- a/PluralKit.Bot/Commands/Misc.cs +++ b/PluralKit.Bot/Commands/Misc.cs @@ -94,7 +94,7 @@ namespace PluralKit.Bot { public async Task PermCheckGuild(Context ctx) { DiscordGuild guild; - DiscordMember senderGuildUser; + DiscordMember senderGuildUser = null; if (ctx.Guild != null && !ctx.HasNext()) { @@ -108,9 +108,8 @@ namespace PluralKit.Bot { throw new PKSyntaxError($"Could not parse `{guildIdStr}` as an ID."); guild = ctx.Client.GetGuild(guildId); - if (guild == null) throw Errors.GuildNotFound(guildId); - senderGuildUser = await guild.GetMember(ctx.Author.Id); - if (senderGuildUser == null) throw Errors.GuildNotFound(guildId); + if (guild != null) senderGuildUser = await guild.GetMember(ctx.Author.Id); + if (guild == null || senderGuildUser == null) throw Errors.GuildNotFound(guildId); } var requiredPermissions = new []