diff --git a/PluralKit.Bot/Bot.cs b/PluralKit.Bot/Bot.cs index 6764b5e6..7d7d7cad 100644 --- a/PluralKit.Bot/Bot.cs +++ b/PluralKit.Bot/Bot.cs @@ -283,7 +283,7 @@ namespace PluralKit.Bot // Fetch information about the guild early, as we need it for the logger cleanup GuildConfig cachedGuild = default; - if (msg.Channel.Type == ChannelType.Text) await _cache.GetGuildDataCached(msg.Channel.GuildId); + if (msg.Channel.Type == ChannelType.Text) cachedGuild = await _cache.GetGuildDataCached(msg.Channel.GuildId); // Pass guild bot/WH messages onto the logger cleanup service, but otherwise ignore if (msg.Author.IsBot && msg.Channel.Type == ChannelType.Text) diff --git a/PluralKit.Bot/Commands/MemberAvatar.cs b/PluralKit.Bot/Commands/MemberAvatar.cs index 0e0b8916..a02dabdd 100644 --- a/PluralKit.Bot/Commands/MemberAvatar.cs +++ b/PluralKit.Bot/Commands/MemberAvatar.cs @@ -61,7 +61,7 @@ namespace PluralKit.Bot if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError; else if (user != null) { - if (user.AvatarUrl == user.DefaultAvatarUrl) throw Errors.UserHasNoAvatar; //TODO: is this necessary? + if (!user.HasAvatar()) throw Errors.UserHasNoAvatar; //TODO: is this necessary? target.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256); await _data.SaveMember(target); @@ -131,7 +131,7 @@ namespace PluralKit.Bot if (user != null) { - if (user.AvatarUrl == user.DefaultAvatarUrl) throw Errors.UserHasNoAvatar; + if (!user.HasAvatar()) throw Errors.UserHasNoAvatar; guildData.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256); await _data.SetMemberGuildSettings(target, ctx.Guild.Id, guildData); diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index 454614a4..ed000be2 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -144,7 +144,7 @@ namespace PluralKit.Bot var member = await ctx.MatchUser(); if (member != null) { - if (member.AvatarUrl == member.DefaultAvatarUrl) throw Errors.UserHasNoAvatar; + if (!member.HasAvatar()) throw Errors.UserHasNoAvatar; ctx.System.AvatarUrl = member.GetAvatarUrl(ImageFormat.Png, size: 256); await _data.SaveSystem(ctx.System); diff --git a/PluralKit.Bot/Extensions.cs b/PluralKit.Bot/Extensions.cs index b5434e5c..ad9da5a6 100644 --- a/PluralKit.Bot/Extensions.cs +++ b/PluralKit.Bot/Extensions.cs @@ -1,4 +1,5 @@ using DSharpPlus; +using DSharpPlus.Entities; using System.Net.WebSockets; @@ -19,5 +20,10 @@ namespace PluralKit.Bot } return true; } + + public static bool HasAvatar(this DiscordUser user) + { + return user.AvatarUrl != user.DefaultAvatarUrl; + } } }