mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 17:20:14 +00:00
feat: cache Discord DM channels in database
This commit is contained in:
parent
ddbf0e8691
commit
89c44a3482
14 changed files with 127 additions and 48 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue