K
Kord•3mo ago
Tic

Check if embed is removed by user

Hello How can I know if an embed has been removed by the user?
23 Replies
Tic
TicOP•3mo ago
I seen the deferredResponse.getFollowupMessage(XXX) but .. how can I get the message ID?
gdude
gdude•3mo ago
the message will be edited and the embed will be gone you get the ID as part of the interaction response
Tic
TicOP•3mo ago
Which property? 🤔
No description
gdude
gdude•3mo ago
not sure, but it's in whatever is returned by the creation function
Tic
TicOP•3mo ago
I don't find 🤔
gdude
gdude•3mo ago
check what the edit/delete function does ig
LustigerLurch
LustigerLurch•3mo ago
it will be the id of a followup you created to the intial response - otherwise there are no followups
Tic
TicOP•3mo ago
Ok so, how can I create a followUp 😅? I found something like:
val deferredResponse = interaction.deferPublicResponse()
val msg= deferredResponse.respond {
content = "This command is not implemented yet."
embed {
title = "This command is not implemented yet."
description = "This command is not implemented yet."
}
}
println("First: ${msg.getFollowupMessage(msg.message.id).message.embeds.size}") // 1
delay(5.seconds)
println("Second: ${msg.getFollowupMessage(msg.message.id).message.embeds.size}") // After suppression by user, 0
val deferredResponse = interaction.deferPublicResponse()
val msg= deferredResponse.respond {
content = "This command is not implemented yet."
embed {
title = "This command is not implemented yet."
description = "This command is not implemented yet."
}
}
println("First: ${msg.getFollowupMessage(msg.message.id).message.embeds.size}") // 1
delay(5.seconds)
println("Second: ${msg.getFollowupMessage(msg.message.id).message.embeds.size}") // After suppression by user, 0
It's the good way to verify?
gdude
gdude•3mo ago
What are you trying to achieve here I'm pretty sure users can't edit bot responses
Tic
TicOP•3mo ago
He can click on the closs at the top right of an embed and after that, if the bot tries to update the embed, the message is modified but the embed removed (never appears again)
gdude
gdude•3mo ago
I don't think it makes sense to worry about that Why would that happen?
Tic
TicOP•3mo ago
Because the buttons continue to work. So in my paginator, the user can continue to change the page, but no info can be display (because embed integration is removed by user), so I would like to cancel the process to stop lifecycle linked to the paginator, returns a error message to the user saying "Integration removed" etc.
gdude
gdude•3mo ago
A user can't realistically expect an embed to work if they remove the embeds It doesn't make sense to account for that, you can't prevent every piece of user error That said, removing embeds triggers a message update event I think? Make sure you checked that
Tic
TicOP•3mo ago
I don't think so 🤔 but maybe it's something to check of course, but it's also to avoid consuming resources (CPU, RAM) because the paginator don't work anymore and stop the process consequently
gdude
gdude•3mo ago
Wouldn't you time it out anyway? All KordEx paginators time out by default
Tic
TicOP•3mo ago
There is a timeout system, but stop the system instantly when the embed is removed is better than wait X minutes
gdude
gdude•3mo ago
I doubt it'll be much of a performance problem compared to you polling each followup message from cache
LustigerLurch
LustigerLurch•3mo ago
you can bring the embed back by adding suppressEmbeds = false to the message (modify) builder it sets MessageFlag.SuppressEmbeds in the flags of the message. you should also be able to use that flag to determine when the embeds are removed by a user.
gdude
gdude•3mo ago
That's useful info, gg
Tic
TicOP•3mo ago
oh? interesting thanks I will try That works, nice so followup message is not necessary for my need Ah .. maybe yes to verify if the message is deleted or not So the mix between: - supressEmbed to keep the integration updated - LiveMessage to receive information when message is deleted Resolve my issue, thanks a lot In the same context, LiveMessage are with preview annotations since .. 2-3 years I think, maybe we should remove the preview state? @LustigerLurch
LustigerLurch
LustigerLurch•3mo ago
tbh, i have basically never touched those so i'm not sure how they work
Tic
TicOP•3mo ago
Basically, create a system that listen event from discord and call registered handler if it's not a deletion I worked on it partially, it was before the add of interaction
Tic
TicOP•3mo ago
Want results from more Discord servers?
Add your server