Collector not updating message embed

No errors in console or anything,
/** @type string */
let list = intr.options.getString("name", true)
let page = 1
let levelsppage = intr.options.getInteger("levels-per-page", false) ?? 5
let embed = await createEmbedForList(list, levelsppage, page)
let response = await intr.reply(embed)

let collector = response.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 120_000
})

collector.on("collect", async collectorIntr => {
console.log("collection moment")
if (collectorIntr.user.id !== intr.user.id) {
// wrong person!
await collectorIntr.reply({
content: "This is not your list! Use /list to create your own.",
ephemeral: true
})
return
}

switch(collectorIntr.customId) {
case "page-prev":
await collectorIntr.update(createEmbedForList(list, levelsppage, --page))
break
case "page-next":
await collectorIntr.update(createEmbedForList(list, levelsppage, ++page))
break
default:
// uh oh
console.warn("uh oh %s", collectorIntr.customId)
}
})

collector.on("end", async () => {
console.log("timeout")
let embed = await createEmbedForList(list, levelsppage, page)
embed.components[0].components[0].setDisabled(true)
embed.components[0].components[1].setDisabled(true)
intr.editReply(embed)
})
/** @type string */
let list = intr.options.getString("name", true)
let page = 1
let levelsppage = intr.options.getInteger("levels-per-page", false) ?? 5
let embed = await createEmbedForList(list, levelsppage, page)
let response = await intr.reply(embed)

let collector = response.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 120_000
})

collector.on("collect", async collectorIntr => {
console.log("collection moment")
if (collectorIntr.user.id !== intr.user.id) {
// wrong person!
await collectorIntr.reply({
content: "This is not your list! Use /list to create your own.",
ephemeral: true
})
return
}

switch(collectorIntr.customId) {
case "page-prev":
await collectorIntr.update(createEmbedForList(list, levelsppage, --page))
break
case "page-next":
await collectorIntr.update(createEmbedForList(list, levelsppage, ++page))
break
default:
// uh oh
console.warn("uh oh %s", collectorIntr.customId)
}
})

collector.on("end", async () => {
console.log("timeout")
let embed = await createEmbedForList(list, levelsppage, page)
embed.components[0].components[0].setDisabled(true)
embed.components[0].components[1].setDisabled(true)
intr.editReply(embed)
})
createEmbedForList returns an object containing
{
embeds: [ Embed ],
components: [ ActionRow ]
}
{
embeds: [ Embed ],
components: [ ActionRow ]
}
2 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
undefined
undefinedOP7mo ago
djs 14.15.3 and node 20.10.0 if anyone needs more code to test then just let me know i assume I'm doing something wrong in my switch statement but not sure what the message doesnt update as (edited) either oh and intr is the interaction (CommandInteraction) and "collection moment" does actually get logged to the console and also the page value does update so it's not just creating the page 1 embed every time and yet the end event also fires and disables the buttons oh my god I think it could be because I'm not awaiting the createEmbedForList yep that was it
Want results from more Discord servers?
Add your server