Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Commit 7016eff

Browse files
committed
fix: /roles should not remove roles other than server roles
1 parent 5b3d22f commit 7016eff

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/interactions/selects/setServerRole.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MessageComponentInteraction, SelectMenuInteraction } from "discord.js";
22
import { ComponentInteractionHandler } from "../../lib/interaction";
3-
import { createRolesMessage } from "../../lib/makigas/roles";
3+
import { createRolesMessage, ROLE_DEFINITIONS } from "../../lib/makigas/roles";
44

55
function difference(a: string[], b: string[]): string[] {
66
return a.filter((i) => !b.includes(i));
@@ -13,7 +13,10 @@ export default class ModMenuAlert implements ComponentInteractionHandler {
1313
if (event.inGuild()) {
1414
/* event.member might not contain the information we are interested in. */
1515
const member = await event.guild.members.fetch(event.user.id);
16-
const currentRoles = member.roles.cache.map((role) => role.name);
16+
const acceptableRoles = ROLE_DEFINITIONS.map((r) => r.label);
17+
const currentRoles = member.roles.cache
18+
.map((role) => role.name)
19+
.filter((r) => acceptableRoles.includes(r));
1720
const desiredRoles = event.values;
1821

1922
/* Set and unset roles that should not apply here. */

src/lib/makigas/roles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
* this code, you should probably change this with the list of roles that you are using
1212
* for your server...
1313
*/
14-
const ROLE_DEFINITIONS = [
14+
export const ROLE_DEFINITIONS = [
1515
{
1616
label: "Anuncios",
1717
description: "Te menciono cuando tenga algo que anunciar",

0 commit comments

Comments
 (0)