feat: cache Discord DM channels in database

This commit is contained in:
spiral 2022-01-22 02:47:47 -05:00
parent ddbf0e8691
commit 89c44a3482
No known key found for this signature in database
GPG key ID: A6059F0CA0E1BD31
14 changed files with 127 additions and 48 deletions

View file

@ -58,17 +58,6 @@ public static class CacheExtensions
return restChannel;
}
public static async Task<Channel> GetOrCreateDmChannel(this IDiscordCache cache, DiscordApiClient rest,
ulong recipientId)
{
if (await cache.TryGetDmChannel(recipientId) is { } cacheChannel)
return cacheChannel;
var restChannel = await rest.CreateDm(recipientId);
await cache.SaveChannel(restChannel);
return restChannel;
}
public static async Task<Channel> GetRootChannel(this IDiscordCache cache, ulong channelOrThread)
{
var channel = await cache.GetChannel(channelOrThread);