Skip to content

feat: delete-all button and language dropdown for multi-message code blocks#550

Open
Neil-Tomar wants to merge 3 commits into
Java-Discord:mainfrom
Neil-Tomar:feat/format-code-message-linking
Open

feat: delete-all button and language dropdown for multi-message code blocks#550
Neil-Tomar wants to merge 3 commits into
Java-Discord:mainfrom
Neil-Tomar:feat/format-code-message-linking

Conversation

@Neil-Tomar

Copy link
Copy Markdown
Contributor

What

Multi-message formatted code blocks now have two interactions, backed by a small message-linking helper:

  • Delete-all button — removes every message of the block in one click
  • Language dropdown (ephemeral) — re-colors every chunk to a chosen language

How

  • LinkedMessages resolves the block from the component's message (getHistoryBefore/After), touching only the bot's own messages.
  • FormatCodeInteractionHandler handles the delete button and the language dropdown.
  • Permission: requester / staff / owner (same rule as the existing delete button).

Open questions

  • The language dropdown is ephemeral per your suggestion, so it's a one-time picker that's gone on reload — happy to make it a permanent public control instead.
  • Rare edge case: two simultaneous formats could interleave bot messages; the resolver is best-effort there.

…ching

Delete-all button removes every message of a block; ephemeral language dropdown re-colors every chunk. Only the bot's own messages are touched.
@Neil-Tomar Neil-Tomar requested a review from a team as a code owner July 4, 2026 15:41
@Neil-Tomar Neil-Tomar requested a review from danthe1st July 5, 2026 13:24
@Neil-Tomar Neil-Tomar requested a review from danthe1st July 5, 2026 16:34
* @return an action row containing the language dropdown
*/
public static ActionRow buildLanguageMenu(long requesterId, int total) {
return ActionRow.of(languageMenu(ComponentIdBuilder.build(COMPONENT_ID, requesterId, total)));

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.

I noticed it's possible to do the following:

  • User A runs the format code command
  • User B runs the format code command
  • User A deletes the code they formatted
  • User A changes the language from their ephemeral message

In this case, the language of the code block of user B is changed. Could you prevent this in one of the following ways?

  • In LinkedMessages.resolveAfter, check that the last message contains the delete button with the delete button with the correct requestor (= current user) and that no other messages have a delete button
  • Change the ephemeral message to be sent after the formatted codeblocks, use resolveBefore and add an additional argument containing the message ID of the first code block message to the ID here. If this doesn't match, it is a failure.

I think the first approach is easier to do so I recommend that one.

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.

2 participants