Port the DM stuff

This commit is contained in:
Ske
2020-12-25 13:58:45 +01:00
parent a2c8cbb560
commit 9079f1c59c
15 changed files with 95 additions and 77 deletions

View File

@@ -55,6 +55,17 @@ namespace Myriad.Extensions
return restUser;
}
public static async ValueTask<Channel?> GetOrFetchChannel(this IDiscordCache cache, DiscordApiClient rest, ulong channelId)
{
if (cache.TryGetChannel(channelId, out var cacheChannel))
return cacheChannel;
var restChannel = await rest.GetChannel(channelId);
if (restChannel != null)
await cache.SaveChannel(restChannel);
return restChannel;
}
public static async Task<Channel> GetOrCreateDmChannel(this IDiscordCache cache, DiscordApiClient rest, ulong recipientId)
{
if (cache.TryGetDmChannel(recipientId, out var cacheChannel))