secre
secre
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by secre on 2/14/2024 in #djs-questions
Interactions overlapping? (I don't know what even happening anymore)
I have command that sends a ephemeral message with buttons, and then using message collector to get response from buttons.
const componentCollector = message.channel.createMessageComponentCollector({
filter: (int) => (int.user.id === interaction.user.id),
componentType: ComponentType.Button,
time: 60_000,
message,
max: 1,
})
const componentCollector = message.channel.createMessageComponentCollector({
filter: (int) => (int.user.id === interaction.user.id),
componentType: ComponentType.Button,
time: 60_000,
message,
max: 1,
})
I have a function that handles response:
componentCollector.on("collect", (buttonInteraction) => {
handleSelectedConvertType(buttonInteraction, interaction) // interaction - is initial interaction that comes when user executed /command
componentCollector.stop("collected")
})
componentCollector.on("collect", (buttonInteraction) => {
handleSelectedConvertType(buttonInteraction, interaction) // interaction - is initial interaction that comes when user executed /command
componentCollector.stop("collected")
})
In this function i'm getting options that user provide when executed /command, and creating some embeds with description Problem is here:
randomSelectedEmbed.description = randomSelectedEmbed.description.replace(
"%link%",
initialInteraction.user.toString()
)
randomSelectedEmbed.description = randomSelectedEmbed.description.replace(
"%link%",
initialInteraction.user.toString()
)
And somehow if two users manage to click button on the same time initialInteraction.user.toString() will be not what we expect. For example: I clicked button and should see in response my mention, but I see mention of my friend that manage to click it on the same time If I use buttonInteraction instead - all works fine. But i'm curious why initialInetraction picking up different user
51 replies