#long thing

1 messages · Page 1 of 1 (latest)

opaque scaffold
gloomy stirrup
#

idk why my code doesn't work.

calm meteorBOT
#

To help you we need more information:
• What are you trying to do?
• What is your code?
• What errors and debug logs do you have?

#

To help you we need more information:
• What are you trying to do?
• What is your code?
• What errors and debug logs do you have?

gloomy stirrup
#

trying to push some buttons in the row if role isn't undefined

#
data.inventory.roles.forEach(async(data, i) => {
            let checker = await interaction.guild.roles.fetch(`${data.id}`)
            if(checker == undefined) {
                return await statisticSchema.findOneAndUpdate({id: interaction.member.id},
                                                    {$pull: { inventory: { roles: { id: data.id } } }})
            } else {
                list.push(
                    `**${i + 1}**. ${`<@&${data.id}>`} **—** **[${data.hidden !== true ? ':visible:' : ':invisible:'}]**`
                );
                buttons.push(new MessageButton()
                    .setStyle("PRIMARY")
                    .setLabel(`${i + 1}`)
                    .setCustomId(`${data.id}`))
            }
        })
        const embed = new MessageEmbed()
            .setColor(`${color.invisible}`)
            .setTitle(`Ваш инвентарь личных ролей`)
            .setDescription(`${list.slice(page * 5, page * 5 + 5).join("\n")}`)
            .setThumbnail(interaction.member.user.displayAvatarURL({ dynamic: true }))
            .setFooter({ text: `Страница ${page + 1}/${indo_pages}`, })

        const components = buttonsToRow(buttons)
        if (components.length < 5) {
            if(row.components !== undefined){
                row.components[0].setDisabled(page === 0 ? true : false);
                row.components[2].setDisabled(page === indo_pages - 1 ? true : false);
                await interaction.followUp({ embeds: [embed], components: [components[page], row] })
        } else {
            await interaction.followUp({ embeds: [embed], components: [components[page]] })
        }
}
#
    let type = data.type;
                    ^

TypeError: Cannot read property 'type' of undefined
    at Function.create (C:\Users\hotab\Desktop\Anko\node_modules\discord.js\src\structures\BaseMessageComponent.js:62:21)
    at C:\Users\hotab\Desktop\Anko\node_modules\discord.js\src\structures\MessagePayload.js:141:79
    at Array.map (<anonymous>)
    at MessagePayload.resolveData (C:\Users\hotab\Desktop\Anko\node_modules\discord.js\src\structures\MessagePayload.js:141:49)
    at InteractionWebhook.send (C:\Users\hotab\Desktop\Anko\node_modules\discord.js\src\structures\Webhook.js:191:61)
    at CommandInteraction.followUp (C:\Users\hotab\Desktop\Anko\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:166:25)
    at Object.run (C:\Users\hotab\Desktop\Anko\slash\inventory.js:73:35)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
bronze sand
#

let type = data.type;
^
TypeError: Cannot read property 'type' of undefined

#

do you see that in the code you sent?

gloomy stirrup
#

but where i use data.type idk

edgy crag
#

you dont

#

you would see that if you would read the stacktrace

#

whatever you pass to components is probably undefined