mirror of
https://github.com/RPCS3/discord-bot.git
synced 2024-12-14 06:18:42 +00:00
998c27c966
new isssue detections for log parser consistent reaction with emoji only / text when can't ability to disable commands at runtime (fixes #56) command to check for game updates various other bugfixes
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using CompatBot.Database;
|
|
using DSharpPlus.EventArgs;
|
|
|
|
namespace CompatBot.EventHandlers
|
|
{
|
|
internal static class ThumbnailCacheMonitor
|
|
{
|
|
public static async Task OnMessageDeleted(MessageDeleteEventArgs args)
|
|
{
|
|
if (args.Channel.Id != Config.ThumbnailSpamId)
|
|
return;
|
|
|
|
if (string.IsNullOrEmpty(args.Message.Content))
|
|
return;
|
|
|
|
if (!args.Message.Attachments.Any())
|
|
return;
|
|
|
|
using (var db = new ThumbnailDb())
|
|
{
|
|
var thumb = db.Thumbnail.FirstOrDefault(i => i.ContentId == args.Message.Content);
|
|
if (thumb?.EmbeddableUrl is string url && !string.IsNullOrEmpty(url) && args.Message.Attachments.Any(a => a.Url == url))
|
|
{
|
|
thumb.EmbeddableUrl = null;
|
|
await db.SaveChangesAsync(Config.Cts.Token).ConfigureAwait(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|