mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Do not log messages edited by bots (#202)
If the author of the edited message is a bot, then Octobot won't log the edit
This commit is contained in:
parent
2dc5220f46
commit
4581b402aa
1 changed files with 16 additions and 11 deletions
|
@ -36,18 +36,22 @@ public class MessageEditedResponder : IResponder<IMessageUpdate>
|
||||||
|
|
||||||
public async Task<Result> RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default)
|
public async Task<Result> RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
|
if (!gatewayEvent.ID.IsDefined(out var messageId))
|
||||||
|
{
|
||||||
|
return new ArgumentNullError(nameof(gatewayEvent.ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gatewayEvent.ChannelID.IsDefined(out var channelId))
|
||||||
|
{
|
||||||
|
return new ArgumentNullError(nameof(gatewayEvent.ChannelID));
|
||||||
|
}
|
||||||
|
|
||||||
if (!gatewayEvent.GuildID.IsDefined(out var guildId))
|
if (!gatewayEvent.GuildID.IsDefined(out var guildId))
|
||||||
{
|
{
|
||||||
return Result.FromSuccess();
|
return Result.FromSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg = await _guildData.GetSettings(guildId, ct);
|
if (gatewayEvent.Author.IsDefined(out var author) && author.IsBot.OrDefault(false))
|
||||||
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
|
|
||||||
{
|
|
||||||
return Result.FromSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gatewayEvent.Content.IsDefined(out var newContent))
|
|
||||||
{
|
{
|
||||||
return Result.FromSuccess();
|
return Result.FromSuccess();
|
||||||
}
|
}
|
||||||
|
@ -57,14 +61,15 @@ public class MessageEditedResponder : IResponder<IMessageUpdate>
|
||||||
return Result.FromSuccess(); // The message wasn't actually edited
|
return Result.FromSuccess(); // The message wasn't actually edited
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gatewayEvent.ChannelID.IsDefined(out var channelId))
|
if (!gatewayEvent.Content.IsDefined(out var newContent))
|
||||||
{
|
{
|
||||||
return new ArgumentNullError(nameof(gatewayEvent.ChannelID));
|
return Result.FromSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gatewayEvent.ID.IsDefined(out var messageId))
|
var cfg = await _guildData.GetSettings(guildId, ct);
|
||||||
|
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
|
||||||
{
|
{
|
||||||
return new ArgumentNullError(nameof(gatewayEvent.ID));
|
return Result.FromSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
var cacheKey = new KeyHelpers.MessageCacheKey(channelId, messageId);
|
var cacheKey = new KeyHelpers.MessageCacheKey(channelId, messageId);
|
||||||
|
|
Loading…
Reference in a new issue