(selectInteraction, rootInteraction, panelData, guildId, guild, client)
| 537 | } |
| 538 | |
| 539 | async function handleAddRole(selectInteraction, rootInteraction, panelData, guildId, guild, client) { |
| 540 | await selectInteraction.deferUpdate(); |
| 541 | |
| 542 | if (panelData.roles.length >= 25) { |
| 543 | await replyUserError(selectInteraction, { |
| 544 | type: ErrorTypes.VALIDATION, |
| 545 | message: 'This panel already has the maximum of 25 roles.', |
| 546 | }); |
| 547 | return; |
| 548 | } |
| 549 | |
| 550 | const roleSelect = new RoleSelectMenuBuilder() |
| 551 | .setCustomId('rr_add_role_pick') |
| 552 | .setPlaceholder('Select a role to add...') |
| 553 | .setMaxValues(1); |
| 554 | |
| 555 | await selectInteraction.followUp({ |
| 556 | embeds: [ |
| 557 | new EmbedBuilder() |
| 558 | .setTitle('Add Role') |
| 559 | .setDescription( |
| 560 | `**Current roles:** ${panelData.roles.length}/25\n\nSelect a role to add to this panel.`, |
| 561 | ) |
| 562 | .setColor(getColor('info')), |
| 563 | ], |
| 564 | components: [new ActionRowBuilder().addComponents(roleSelect)], |
| 565 | flags: MessageFlags.Ephemeral, |
| 566 | }); |
| 567 | |
| 568 | const roleCollector = rootInteraction.channel.createMessageComponentCollector({ |
| 569 | componentType: ComponentType.RoleSelect, |
| 570 | filter: i => |
| 571 | i.user.id === selectInteraction.user.id && i.customId === 'rr_add_role_pick', |
| 572 | time: 60_000, |
| 573 | max: 1, |
| 574 | }); |
| 575 | |
| 576 | roleCollector.on('collect', async roleInteraction => { |
| 577 | await roleInteraction.deferUpdate(); |
| 578 | const role = roleInteraction.roles.first(); |
| 579 | |
| 580 | if (panelData.roles.includes(role.id)) { |
| 581 | await replyUserError(roleInteraction, { |
| 582 | type: ErrorTypes.VALIDATION, |
| 583 | message: `${role} is already in this panel.`, |
| 584 | }); |
| 585 | return; |
| 586 | } |
| 587 | if (role.id === guild.id) { |
| 588 | await replyUserError(roleInteraction, { |
| 589 | type: ErrorTypes.VALIDATION, |
| 590 | message: 'You cannot use @everyone.', |
| 591 | }); |
| 592 | return; |
| 593 | } |
| 594 | if (role.managed) { |
| 595 | await replyUserError(roleInteraction, { |
| 596 | type: ErrorTypes.VALIDATION, |
nothing calls this directly
no test coverage detected