Ignore self-messages

This commit is contained in:
Ske 2020-09-20 21:49:52 +02:00
parent 6f8e15178f
commit eab1cb1645
2 changed files with 7 additions and 1 deletions

View File

@ -50,6 +50,7 @@ namespace PluralKit.Bot
public async Task Handle(MessageCreateEventArgs evt)
{
if (evt.Author?.Id == _client.CurrentUser?.Id) return;
if (evt.Message.MessageType != MessageType.Default) return;
if (IsDuplicateMessage(evt.Message)) return;

View File

@ -2,6 +2,7 @@ using System.Threading.Tasks;
using App.Metrics;
using DSharpPlus;
using DSharpPlus.EventArgs;
using PluralKit.Core;
@ -16,18 +17,22 @@ namespace PluralKit.Bot
private readonly IDatabase _db;
private readonly ModelRepository _repo;
private readonly IMetrics _metrics;
private readonly DiscordShardedClient _client;
public MessageEdited(LastMessageCacheService lastMessageCache, ProxyService proxy, IDatabase db, IMetrics metrics, ModelRepository repo)
public MessageEdited(LastMessageCacheService lastMessageCache, ProxyService proxy, IDatabase db, IMetrics metrics, ModelRepository repo, DiscordShardedClient client)
{
_lastMessageCache = lastMessageCache;
_proxy = proxy;
_db = db;
_metrics = metrics;
_repo = repo;
_client = client;
}
public async Task Handle(MessageUpdateEventArgs evt)
{
if (evt.Author?.Id == _client.CurrentUser?.Id) return;
// Edit message events sometimes arrive with missing data; double-check it's all there
if (evt.Message.Content == null || evt.Author == null || evt.Channel.Guild == null) return;