mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Fix removed roles store being overwritten
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
620c706c97
commit
7f0fd6ffb5
2 changed files with 8 additions and 5 deletions
|
@ -37,6 +37,7 @@ public sealed class MuteCommand : ICommand {
|
|||
var memberData = data.MemberData[toMute.Id];
|
||||
|
||||
if (role is not null) {
|
||||
memberData.MutedUntil = DateTimeOffset.Now.Add(duration);
|
||||
if (data.Preferences["RemoveRolesOnMute"] is "true") {
|
||||
memberData.Roles = toMute.RoleIds.ToList();
|
||||
memberData.Roles.Remove(cmd.Context.Guild.Id);
|
||||
|
@ -58,7 +59,6 @@ public sealed class MuteCommand : ICommand {
|
|||
await toMute.SetTimeOutAsync(duration, requestOptions);
|
||||
}
|
||||
|
||||
memberData.MutedUntil = DateTimeOffset.Now.Add(duration);
|
||||
cmd.ConfigWriteScheduled = true;
|
||||
|
||||
var feedback = string.Format(
|
||||
|
|
|
@ -7,8 +7,8 @@ using Discord.WebSocket;
|
|||
namespace Boyfriend;
|
||||
|
||||
public static class EventHandler {
|
||||
private static readonly DiscordSocketClient Client = Boyfriend.Client;
|
||||
private static bool _sendReadyMessages = true;
|
||||
private static readonly DiscordSocketClient Client = Boyfriend.Client;
|
||||
private static bool _sendReadyMessages = true;
|
||||
|
||||
public static void InitEvents() {
|
||||
Client.Ready += ReadyEvent;
|
||||
|
@ -26,8 +26,11 @@ public static class EventHandler {
|
|||
|
||||
private static Task MemberRolesUpdatedEvent(Cacheable<SocketGuildUser, ulong> oldUser, SocketGuildUser newUser) {
|
||||
var data = GuildData.Get(newUser.Guild).MemberData[newUser.Id];
|
||||
data.Roles = ((IGuildUser)newUser).RoleIds.ToList();
|
||||
data.Roles.Remove(newUser.Guild.Id);
|
||||
if (data.MutedUntil is null) {
|
||||
data.Roles = ((IGuildUser)newUser).RoleIds.ToList();
|
||||
data.Roles.Remove(newUser.Guild.Id);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue