Skip to content

add deter_update and update instructions to discordinteraction - #66

Open
BehrRiley wants to merge 3 commits into
DenizenScript:masterfrom
BehrRiley:feature/discord-interaction-updates
Open

add deter_update and update instructions to discordinteraction#66
BehrRiley wants to merge 3 commits into
DenizenScript:masterfrom
BehrRiley:feature/discord-interaction-updates

Conversation

@BehrRiley

Copy link
Copy Markdown

Summary

adds support for the two missing component-interaction response modes to discordinteraction; discord thread reference: (ikuria) discord buttonpress without alert. this feature request only included one of two missing components, however Discord describes the two callbacks elaborated below as a pair:

  • defer_update for Discord DEFERRED_UPDATE_MESSAGE callback (type 6)
  • update for Discord UPDATE_MESSAGE callback (type 7)

these are specifically intended for button/select-menu interactions.
relevant documentation for reference: https://docs.discord.com/developers/interactions/receiving-and-responding#interaction-response-object

Problem

dDiscordBot previously supported normal interaction replies/deferred replies and editing the interaction’s original response, but didn't provide the two component-specific acknowledgement/update paths:

  • a component interaction could not be acknowledged without Discord showing the normal deferred-reply loading state
  • a component interaction could not immediately update the message it originated from as its initial response

Changes

  • added defer_update using JDA’s IMessageEditCallback.deferEdit()
    • requires a message-edit-capable interaction
    • acknowledges the component interaction without the normal Thinking... state
    • allows the existing edit instruction to update the original component message afterwards
  • added update using JDA’s IMessageEditCallback.editMessage(MessageEditData)
    • requires a message-edit-capable interaction
    • immediately edits the original component message as the initial interaction response
  • updated discordinteraction meta for the new instructions

previously, terms like defer, reply, and edit could be ambiguous; with defer_update and update, the meta should make that distinction now:

  • defer is to acknowledge now, reply later
  • defer_update is to acknowledge a component now, update it's message later
  • reply is to respond with a message
  • update is to immediately update the component's message
  • edit is to edit an already-established interaction response
    the change isn't just for the new extra documentation, it makes the command names and their different Discord behaviors easier to understand now

Testing

  • Tested live with Champagne using real Discord buttons:
image
  • update: clicking the test button immediately edited the message containing that button; no followup was created and Discord displayed no interaction failure
  • defer_update: clicking the test button acknowledged immediately without a visible loading/thinking/typing states; after a two-second delay, existing edit updated the same original component message.
  • other behaviors tested just to be sure:
    • defer followed by edit
    • reply
    • delete

The test-server startup log includes unrelated warnings during startup; the server, Denizen, dDiscordBot, and JDA all completed startup normally; these warnings aren't relevant and don't affect the interaction tests

here's a startup log referencing this test with everything above:
https://files.behr.dev/file-share/dDiscordBot-0.7.1-interaction-updates-latest.log.txt

a working build of my latest successful build which has no errors can be built with this branch or found at:
https://files.behr.dev/file-share/dDiscordBot-0.7.1-interaction-updates.jar

- add `defer_update` to acknowledge a component interaction without a loading state
- add `update` to immediately edit the original message of a component interaction
- require `IMessageEditCallback` validation for the new instructions
- update meta to clarify differences between `defer`, `defer_update`, `edit`, and `update`
- add meta usage examples for the new instructions
yield ((IReplyCallback) interaction.interaction).deferReply(ephemeral);
}
case DEFER_UPDATE -> {
if (!(interaction.interaction instanceof IMessageEditCallback)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use pattern matching here.

// 'defer_update' acknowledges a component interaction without a loading state, allowing its original message to be edited later.
// 'reply' provides the initial interaction response, or sends a followup after the interaction has been acknowledged. It uses similar logic to normal messaging. See <@link command discordmessage>.
// 'update' immediately updates the message associated with a component interaction as its initial response.
// 'edit' edits the interaction's original response through its interaction hook, and 'delete' deletes that original response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are two different options, they should be on separate lines.

- apply review feedback for component interaction updates
- use pattern matching for message edit callbacks, clarify the individual
interaction instructions, and document update and deferred-update usage meta
// Use to silently acknowledge a component interaction, then update its original message later.
// - ~discordinteraction defer_update interaction:<context.interaction>
// - wait 2s
// - discordinteraction edit interaction:<context.interaction> Updated after processing.

@MC-Samuel MC-Samuel Sep 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text containing multiple words, if part of the same argument, should be surrounded by quotation marks.

@mcmonkey4eva mcmonkey4eva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and doc changes look clean and proper to me at a skim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants