1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-19 16:33:36 +03:00

Do not clear BannedUntil if automatic unbanning wasn't successful

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-06-11 17:01:13 +05:00
parent 9c080d9691
commit f4738e5dd4
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
2 changed files with 4 additions and 2 deletions

View file

@ -163,6 +163,7 @@ public class BanCommandGroup : CommandGroup {
/// was unbanned and vice-versa.
/// </returns>
/// <seealso cref="BanUserAsync" />
/// <seealso cref="GuildUpdateService.TickGuildAsync"/>
[Command("unban")]
[RequireContext(ChannelContext.Guild)]
[RequireDiscordPermission(DiscordPermission.BanMembers)]

View file

@ -33,9 +33,10 @@ public class GuildUpdateService : BackgroundService {
foreach (var memberData in data.MemberData.Values)
if (DateTimeOffset.UtcNow > memberData.BannedUntil) {
_ = _guildApi.RemoveGuildBanAsync(
var unbanResult = await _guildApi.RemoveGuildBanAsync(
guildId, memberData.Id.ToDiscordSnowflake(), Messages.PunishmentExpired.EncodeHeader(), ct);
memberData.BannedUntil = null;
if (unbanResult.IsSuccess)
memberData.BannedUntil = null;
}
}
}