#thread

1 messages · Page 1 of 1 (latest)

autumn totem
#

the sm is annoying help here?

#

ok so i logged (button)

#
ButtonBuilder {
  data: {
    type: 2,
    emoji: undefined,
    custom_id: 'srules',
    label: 'Server Rules',
    style: 2
  }
}
#

this is wht i got

proper notch
#

send full error and code(full) again

autumn totem
#

ok

#

the code contains a long embed tho

proper notch
#

its ok, you can send it using services like sourcebin

autumn totem
#
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const { execute } = require("../server/donate");

module.exports = {
    data: new SlashCommandBuilder()
            .setName('rules')
            .setDescription('View the rules of the server or bot')
            .addSubcommand(subcommand =>
                subcommand
                        .setName('server')
                        .setDescription('View the rules of the server'))
            .addSubcommand(subcommand =>
                subcommand 
                        .setName('bot')
                        .setDescription('View the rules of the bot!')),
    
        /**
         * 
         * @param {Client} client 
         * @param {ChatInputCommandInteraction} interaction 
         */


    async execute(client, interaction, args) {
        const button = new ButtonBuilder()
            .setCustomId('srules')
            .setLabel('Server Rules')
            .setStyle(ButtonStyle.Secondary)

        if (interaction.commandName === 'rules') {
        if (interaction.options.getSubcommand() === 'server') {
            const sembed = new EmbedBuilder()
                .setColor("Random")
                .setTitle("![a_flameYellow](https://cdn.discordapp.com/emojis/776781138039406632.webp?size=128 "a_flameYellow")  RULES ![a_flameYellow](https://cdn.discordapp.com/emojis/776781138039406632.webp?size=128 "a_flameYellow")")
                .setDescription("Breaking these rules leaves you subject to punishment by the staff members. Follow them and we wont have a problem, but don't and we will most likely have an issue. These rules are subject to change at anytime for any reason.")
                .setAuthor({ name: `${interaction.guild.name}`, iconURL: interaction.guild.iconURL({dynamic : true}), url: 'https://discord.gg/gUwCbqpYjz' })
                .setFooter({ text: "Breaking any of these rules are punishable depending the offense.", iconURL: interaction.guild.iconURL({dynamic : true}) })
                
                await interaction.reply({ components: [new ActionRowBuilder().addComponents(button)], embeds: [sembed], ephemeral: true })
                console.log(button)
            } // Server rules ends here.
        }

    }
}```
#

components/buttons/rules.js - js module.exports = { data: { name: `srules` }, async execute(interaction, client) { await interaction.reply({ content: `Hello!` }); } }

#

handlers/loadcomponents.js -

const { readdirSync, read } = require('fs');

module.exports = (client) => {
    client.handleComponents = async () => {
        const componentFolders = readdirSync(`../Components`);
        for (const folder of componentFolders) {
            const componentFiles = readdirSync(`../Components/${folder}`).filter(
                (file) => file.endsWith('.js')
            );

            const { buttons } = client;

            switch (folder) {
                case "buttons":
                    for (const file of componentFiles) {
                        const button = require(`../Components/${folder}/${file}`);
                        buttons.set(button.data.name, button);
                    }
                    break;

                default:
                    break;
            }
        }
    };
};```
proper notch
#

it occurs when subcommand is server?

autumn totem
#

??

autumn totem
proper notch
#

so it console logs but doesn't reply?

autumn totem
#

yeah

proper notch
#

🤔

#

could you send screenshot of what it prints?

autumn totem
proper notch
#

no, in discord

autumn totem
#

oh

proper notch
#

wait so error comes not from slash command but from button?

autumn totem
#

yeah

proper notch
#

how are you handling for button interaction create

autumn totem
#
else if (interaction.isButton()) {
            const { buttons } = client;
            const { customId } = interaction;
            const button = buttons.get(customId);
            if (!button) return new Error('There is no code for this button!');

            try {
                await button.execute(interaction, client);
            } catch (err) {
                console.error(err);
            }```
#

whole code -

const { Client } = require("discord.js");
const color = require("colors");

module.exports = {
    name: "interactionCreate",

    /**
     * 
     * @param {ChatInput} interaction
     * @param {Client} client
     */

    async execute(interaction, client) {
        if (interaction.isChatInputCommand()) {
            if (interaction.user.bot) return;
            const command = client.slashCommands.get(interaction.commandName);
            if (!command) {
                interaction.reply({
                    ephemeral: true,
                    content: "This command is outdated!"
                });
            };
            try {
                command.execute(client, interaction);
            } catch (error) {
                console.log(`${color.bold.red(`[INTERACTION > CREATE : ERROR]`)} ` + `${error}`.bgRed);
            }
        } else if (interaction.isButton()) {
            const { buttons } = client;
            const { customId } = interaction;
            const button = buttons.get(customId);
            if (!button) return new Error('There is no code for this button!');

            try {
                await button.execute(interaction, client);
            } catch (err) {
                console.error(err);
            }
        }
    }
};```
proper notch
#

log button before if(!button)

autumn totem
#

undefined

proper notch
autumn totem
#

??

proper notch
#

it looks like you didn't execute it