diff --git a/Myriad/Extensions/CacheExtensions.cs b/Myriad/Extensions/CacheExtensions.cs index c72da3fb..02802172 100644 --- a/Myriad/Extensions/CacheExtensions.cs +++ b/Myriad/Extensions/CacheExtensions.cs @@ -40,7 +40,7 @@ namespace Myriad.Extensions public static Role GetRole(this IDiscordCache cache, ulong roleId) { if (!cache.TryGetRole(roleId, out var role)) - throw new KeyNotFoundException($"User {roleId} not found in cache"); + throw new KeyNotFoundException($"Role {roleId} not found in cache"); return role; } diff --git a/PluralKit.Bot/Services/EmbedService.cs b/PluralKit.Bot/Services/EmbedService.cs index cdb64831..6d0e8c3c 100644 --- a/PluralKit.Bot/Services/EmbedService.cs +++ b/PluralKit.Bot/Services/EmbedService.cs @@ -331,9 +331,16 @@ namespace PluralKit.Bot var roles = memberInfo?.Roles?.ToList(); if (roles != null && roles.Count > 0) { - // TODO: what if role isn't in cache? figure out a fallback var rolesString = string.Join(", ", roles - .Select(id => _cache.GetRole(id)) + .Select(id => { + _cache.TryGetRole(id, out var role); + if (role != null) + return role; + return new Role() { + Name = "*(unknown role)*", + Position = 0, + }; + }) .OrderByDescending(role => role.Position) .Select(role => role.Name)); eb.Field(new($"Account roles ({roles.Count})", rolesString.Truncate(1024)));