Skip to content

fix error response of /format-code #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2025

Conversation

danthe1st
Copy link
Member

Currently, /format-code fails to send a reply in case the message ID is not a valid Discord message ID.

image

java.lang.IllegalStateException: This interaction has already been acknowledged or replied to. You can only reply or acknowledge an interaction once!
	at net.dv8tion.jda.internal.requests.restaction.interactions.InteractionCallbackImpl.tryAck(InteractionCallbackImpl.java:87)
	at net.dv8tion.jda.internal.requests.restaction.interactions.InteractionCallbackImpl.queue(InteractionCallbackImpl.java:94)
	at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:577)
	at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:543)
	at net.discordjug.javabot.systems.user_commands.format_code.FormatCodeCommand.execute(FormatCodeCommand.java:89)
	at xyz.dynxsty.dih4jda.InteractionHandler.handleSlashCommand(InteractionHandler.java:538)
	at xyz.dynxsty.dih4jda.InteractionHandler.lambda$onSlashCommandInteraction$16(InteractionHandler.java:643)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

This is because the interaction is acknowledged before using event.deferReply().queue();.

Using event.getHook().sendMessageEmbeds() instead of event.replyEmbeds() fixes that as the former works with consecutive messages.

@danthe1st danthe1st requested a review from a team as a code owner June 15, 2025 08:37
@danthe1st danthe1st merged commit 501e271 into Java-Discord:main Jul 12, 2025
2 checks passed
@danthe1st danthe1st deleted the format-code-interaction branch July 12, 2025 10:43
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