mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Resync roles when restarting bot
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
9d5bafbbf5
commit
b1e43611de
2 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Boyfriend.Data;
|
||||
|
@ -86,6 +87,11 @@ public record GuildData {
|
|||
MemberData.Remove(memberData.Id);
|
||||
}
|
||||
|
||||
if (memberData.MutedUntil is null) {
|
||||
memberData.Roles = ((IGuildUser)member).RoleIds.ToList();
|
||||
memberData.Roles.Remove(guild.Id);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ public static class EventHandler {
|
|||
}
|
||||
|
||||
if (memberData.MutedUntil < DateTimeOffset.Now) {
|
||||
if (data.MuteRole is not null)
|
||||
if (data.MuteRole is not null && !user.TimedOutUntil.HasValue)
|
||||
await user.AddRoleAsync(data.MuteRole);
|
||||
if (config["RemoveRolesOnMute"] is "false" && config["ReturnRolesOnRejoin"] is "true")
|
||||
await user.AddRolesAsync(memberData.Roles);
|
||||
|
@ -149,6 +149,7 @@ public static class EventHandler {
|
|||
}
|
||||
|
||||
private static Task UserLeftEvent(SocketGuild guild, SocketUser user) {
|
||||
if (user.IsBot) return Task.CompletedTask;
|
||||
var data = GuildData.Get(guild).MemberData[user.Id];
|
||||
data.IsInGuild = false;
|
||||
data.LeftAt.Add(DateTimeOffset.Now);
|
||||
|
|
Loading…
Reference in a new issue