Issue: Cant update my button, after a change the embed with message.awaitMessageComponent
This is my code :
const message = await interaction.reply({ embeds: [embed], ephemeral: true, components: [row] })
const CollectorFilter = (interaction: { user: { id: any; }; }) => interaction.user.id === interaction.user.id
try {
const Collector = await message.awaitMessageComponent({ filter: CollectorFilter, time: 60_000 })
console.log(Collector.customId)
if (Collector.customId === 'guild') {
returnButton.setDisabled(false)
guildButton.setDisabled(true)
// @ts-ignore
await interaction.editReply({ embeds: [guildembed], components: [row] })
} else if (Collector.customId === 'return') {
returnButton.setDisabled(true)
guildButton.setDisabled(false)
// @ts-ignore
await interaction.editReply({ embeds: [embed], components: [row] })
}
} catch (error) {
await interaction.deleteReply()
}
const message = await interaction.reply({ embeds: [embed], ephemeral: true, components: [row] })
const CollectorFilter = (interaction: { user: { id: any; }; }) => interaction.user.id === interaction.user.id
try {
const Collector = await message.awaitMessageComponent({ filter: CollectorFilter, time: 60_000 })
console.log(Collector.customId)
if (Collector.customId === 'guild') {
returnButton.setDisabled(false)
guildButton.setDisabled(true)
// @ts-ignore
await interaction.editReply({ embeds: [guildembed], components: [row] })
} else if (Collector.customId === 'return') {
returnButton.setDisabled(true)
guildButton.setDisabled(false)
// @ts-ignore
await interaction.editReply({ embeds: [embed], components: [row] })
}
} catch (error) {
await interaction.deleteReply()
}
4 Replies
- 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!i have tested it before, that do the same 😢
did u have any other solution ?
how do i do that ?
ohhh sorryy
im just to tired x)
thats not working 😢
i have fetch the reply like u said, and that work one time, but not the second
oh
like that ?
(if yes, i arldy do that before, and i m just idiot)
bc im idiot
const message = await interaction.reply({ embeds: [embed], ephemeral: true, components: [row], fetchReply: true })
const CollectorFilter = (interaction: { user: { id: any; }; }) => interaction.user.id === interaction.user.id
try {
const Collector = await message.awaitMessageComponent({ filter: CollectorFilter, time: 60000 })
if (Collector.customId === 'guild') {
returnButton.setDisabled(false)
guildButton.setDisabled(true)
await Collector.update({ embeds: [guildembed], components: [row] })
}
else if (Collector.customId === 'return') {
returnButton.setDisabled(true)
guildButton.setDisabled(false)
await Collector.update({ embeds: [embed], components: [row] })
}
const message = await interaction.reply({ embeds: [embed], ephemeral: true, components: [row], fetchReply: true })
const CollectorFilter = (interaction: { user: { id: any; }; }) => interaction.user.id === interaction.user.id
try {
const Collector = await message.awaitMessageComponent({ filter: CollectorFilter, time: 60000 })
if (Collector.customId === 'guild') {
returnButton.setDisabled(false)
guildButton.setDisabled(true)
await Collector.update({ embeds: [guildembed], components: [row] })
}
else if (Collector.customId === 'return') {
returnButton.setDisabled(true)
guildButton.setDisabled(false)
await Collector.update({ embeds: [embed], components: [row] })
}
try {
const Collector = await message.createMessageComponentCollector({ componentType: ComponentType.Button, filter: CollectorFilter, time: 60000 })
Collector.on('collect', async (interaction) => {
await interaction.deferUpdate()
Collector.collected.forEach(async (Collector) => {
if (Collector.customId === 'guild') {
returnButton.setDisabled(false)
guildButton.setDisabled(true)
// @ts-ignore
await interaction.editReply({ embeds: [guildembed], components: [row] })
} else if (Collector.customId === 'return') {
returnButton.setDisabled(true)
guildButton.setDisabled(false)
// @ts-ignore
await interaction.editReply({ embeds: [embed], components: [row] })
}
}
)
})
} catch (error) {
await interaction.deleteReply()
}
try {
const Collector = await message.createMessageComponentCollector({ componentType: ComponentType.Button, filter: CollectorFilter, time: 60000 })
Collector.on('collect', async (interaction) => {
await interaction.deferUpdate()
Collector.collected.forEach(async (Collector) => {
if (Collector.customId === 'guild') {
returnButton.setDisabled(false)
guildButton.setDisabled(true)
// @ts-ignore
await interaction.editReply({ embeds: [guildembed], components: [row] })
} else if (Collector.customId === 'return') {
returnButton.setDisabled(true)
guildButton.setDisabled(false)
// @ts-ignore
await interaction.editReply({ embeds: [embed], components: [row] })
}
}
)
})
} catch (error) {
await interaction.deleteReply()
}