refactor: don't use 'out' in IDiscordCache methods
this change is required for async cache (.NET doesn't support async ref/out params)
This commit is contained in:
@@ -335,10 +335,10 @@ namespace PluralKit.Bot
|
||||
var roles = memberInfo?.Roles?.ToList();
|
||||
if (roles != null && roles.Count > 0 && showContent)
|
||||
{
|
||||
var rolesString = string.Join(", ", roles
|
||||
.Select(id =>
|
||||
var rolesString = string.Join(", ", (await Task.WhenAll(roles
|
||||
.Select(async id =>
|
||||
{
|
||||
_cache.TryGetRole(id, out var role);
|
||||
var role = await _cache.TryGetRole(id);
|
||||
if (role != null)
|
||||
return role;
|
||||
return new Role()
|
||||
@@ -346,7 +346,7 @@ namespace PluralKit.Bot
|
||||
Name = "*(unknown role)*",
|
||||
Position = 0,
|
||||
};
|
||||
})
|
||||
})))
|
||||
.OrderByDescending(role => role.Position)
|
||||
.Select(role => role.Name));
|
||||
eb.Field(new($"Account roles ({roles.Count})", rolesString.Truncate(1024)));
|
||||
|
@@ -93,7 +93,7 @@ namespace PluralKit.Bot
|
||||
private async Task<Channel?> FindLogChannel(ulong guildId, ulong channelId)
|
||||
{
|
||||
// TODO: fetch it directly on cache miss?
|
||||
if (await _cache.TryGetChannel(channelId, out var channel))
|
||||
if (await _cache.TryGetChannel(channelId) is Channel channel)
|
||||
return channel;
|
||||
|
||||
// Channel doesn't exist or we don't have permission to access it, let's remove it from the database too
|
||||
|
Reference in New Issue
Block a user