ghorsington 3 лет назад
Родитель
Сommit
54f4ea9374
1 измененных файлов с 7 добавлено и 12 удалено
  1. 7 12
      bot/src/plugins/violation.ts

+ 7 - 12
bot/src/plugins/violation.ts

@@ -55,17 +55,12 @@ export class ViolationPlugin {
                         settings.muteRoleId);
                     return;
                 }
-                // First mute, then remove other roles
-                await member.roles.add(muteRoleResolve.result);
-                const mute = violation as Mute;
-                if (mute.previousRoles) {
-                    const result = await tryDo(member.roles.remove(mute.previousRoles));
-                    if (!result.ok) {
-                        logger.error("mute: couldn't remove all roles from user %s#%s (%s)!" ,
-                            member.user?.username,
-                            member.user?.discriminator,
-                            member.user?.id);
-                    }
+                const result = await tryDo(member.roles.set([ muteRoleResolve.result ]));
+                if (!result.ok) {
+                    logger.error("mute: Couldn't mute/remove roles for user %s#%s (%s)",
+                        member.user?.username,
+                        member.user?.discriminator,
+                        member.user?.id);
                 }
             },
             stop: async (guild: Guild, userId: string, settings: GuildViolationSettings, violation: TimedViolation): Promise<void> => {
@@ -87,7 +82,7 @@ export class ViolationPlugin {
                 await memberResolve.result.roles.remove(muteRole);
                 const mute = violation as Mute;
                 if (mute.previousRoles) {
-                    const result = await tryDo(memberResolve.result.roles.add(mute.previousRoles));
+                    const result = await tryDo(memberResolve.result.roles.set(mute.previousRoles));
                     if (!result.ok) {
                         logger.warn("mute: couldn't readd all roles for user %s (tried to restore role ids: %s)", memberResolve.result.id, mute.previousRoles.join(", "));
                     }