1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 08:53:36 +03:00

Fix UnknownMember warning flood

If a user was muted using the `MuteRole` method and then banned, the UnknownMember warning will flood your logs when `DateTimeOffset.UtcNow > data.MutedUntil` becomes true, because there is no user in the server to unmute.

Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com>
This commit is contained in:
Macintxsh 2023-09-27 02:06:28 +03:00 committed by GitHub
parent 3a3865ba3d
commit cc0c7c31e8
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23

View file

@ -134,6 +134,12 @@ public sealed partial class MemberUpdateService : BackgroundService
if (DateTimeOffset.UtcNow > data.MutedUntil) if (DateTimeOffset.UtcNow > data.MutedUntil)
{ {
var isOnServer = await _guildApi.GetGuildMemberAsync(guildId, id, ct);
if (!isOnServer.IsSuccess)
{
return Result.FromSuccess();
}
var unmuteResult = await _guildApi.ModifyGuildMemberAsync( var unmuteResult = await _guildApi.ModifyGuildMemberAsync(
guildId, id, roles: data.Roles.ConvertAll(r => r.ToSnowflake()), guildId, id, roles: data.Roles.ConvertAll(r => r.ToSnowflake()),
reason: Messages.PunishmentExpired.EncodeHeader(), ct: ct); reason: Messages.PunishmentExpired.EncodeHeader(), ct: ct);