Cannot read 'edit'

I cannot resolve this error, pls help me to fix it.

collector.on('collect', i => {
if (i.customId === "dropClaim_button") {
buttons.components[0].setDisabled(true)
console.log(i.message)
i.message.edit({ components: [buttons]}).catch(error => {
console.log(error)
})
i.reply({ content: `:gift_wumpus: | <@${i.user.id}> hat den Drop beansprucht!` });
collector.stop() # This is Line 50
}
});
collector.on('end', i => {
buttons.components[0].setDisabled(true)
buttons.components[0].setStyle("Danger")
i.message.edit({ components: [buttons]}).catch(error => { #This is Line 56
console.log(error)
})
})


collector.on('collect', i => {
if (i.customId === "dropClaim_button") {
buttons.components[0].setDisabled(true)
console.log(i.message)
i.message.edit({ components: [buttons]}).catch(error => {
console.log(error)
})
i.reply({ content: `:gift_wumpus: | <@${i.user.id}> hat den Drop beansprucht!` });
collector.stop() # This is Line 50
}
});
collector.on('end', i => {
buttons.components[0].setDisabled(true)
buttons.components[0].setStyle("Danger")
i.message.edit({ components: [buttons]}).catch(error => { #This is Line 56
console.log(error)
})
})

4 Replies
d.js toolkit
d.js toolkit11mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Black_Wither
Black_Wither11mo ago
Oh wait I think I have an idea why it‘s response an error
treble/luna
treble/luna11mo ago
you never reply so there is no message to edit
Black_Wither
Black_Wither11mo ago
No, I just found the error, I entered an i in the end event of the collector, which should stand for the interaction, but of course it has no value, which is why it can't find a message. I fixed it now so that I assigned the message as a variable and can change the message later.