Disabling A Button Through CustomId(handler)

const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits, ButtonStyle, ButtonBuilder, ActionRowBuilder } = require('discord.js');

module.exports = {
    customId: "urgent-ping",
    async execute(interaction, client) {

        if (interaction.user.id !== interaction.channel.ownerId) {
            return await interaction.reply({ content: 'You are not the owner of this thread!', ephemeral: true });
        }

        const staffRole = interaction.guild.roles.cache.get('1325170122134130779');
        const helpfulRole = interaction.guild.roles.cache.get('1325170416020357282');

        const membersToPing = interaction.guild.members.cache.filter(member => 
            (member.roles.cache.has(staffRole.id) || member.roles.cache.has(helpfulRole.id)) &&
            member.presence?.status === 'online' &&
            member.id !== interaction.user.id
        );

        if (membersToPing.size === 0) {
            return await interaction.reply({ content: 'No online members with the required roles to ping.', ephemeral: true });
        }

        const content = membersToPing.map(member => `<@${member.id}> (${member.user.username})`).join('\n');

        await interaction.reply({
            content,
            components: [],
            ephemeral: false
        });
    }
};
Was this page helpful?