#long thing
1 messages · Page 1 of 1 (latest)
idk why my code doesn't work.
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?
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)
let type = data.type;
^
TypeError: Cannot read property 'type' of undefined
do you see that in the code you sent?
but where i use data.type idk