feat: import/export settings, send backup of settings when leaving guild
This commit is contained in:
parent
e6d68338db
commit
db5d7bb4f8
18 changed files with 392 additions and 39 deletions
|
|
@ -24,6 +24,7 @@ public interface IWebhookCache
|
|||
{
|
||||
Task<Webhook?> GetWebhookAsync(ulong channelId);
|
||||
Task SetWebhookAsync(ulong channelId, Webhook webhook);
|
||||
Task RemoveWebhooksAsync(ulong[] channelIds);
|
||||
|
||||
public async Task<Webhook> GetOrFetchWebhookAsync(
|
||||
ulong channelId,
|
||||
|
|
|
|||
|
|
@ -33,4 +33,11 @@ public class InMemoryWebhookCache : IWebhookCache
|
|||
_cache[channelId] = webhook;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task RemoveWebhooksAsync(ulong[] channelIds)
|
||||
{
|
||||
foreach (var id in channelIds)
|
||||
_cache.TryRemove(id, out _);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,8 @@ public class RedisWebhookCache(RedisService redisService) : IWebhookCache
|
|||
public async Task SetWebhookAsync(ulong channelId, Webhook webhook) =>
|
||||
await redisService.SetAsync(WebhookKey(channelId), webhook, 24.Hours());
|
||||
|
||||
public async Task RemoveWebhooksAsync(ulong[] channelIds) =>
|
||||
await redisService.DeleteAsync(channelIds.Select(WebhookKey).ToArray());
|
||||
|
||||
private static string WebhookKey(ulong channelId) => $"webhook:{channelId}";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue