Skip to content

Commit 4345628

Browse files
committed
tests: Use callback response instead of retrieveOriginal()
1 parent 41edf35 commit 4345628

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

src/test/java/io/github/freya022/botcommands/test/commands/slash/SlashEmojis.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import io.github.freya022.botcommands.api.commands.application.ApplicationCommand;
66
import io.github.freya022.botcommands.api.commands.application.slash.GuildSlashEvent;
77
import io.github.freya022.botcommands.api.commands.application.slash.annotations.JDASlashCommand;
8-
import net.dv8tion.jda.api.interactions.InteractionHook;
98
import net.dv8tion.jda.api.interactions.components.buttons.Button;
109
import net.dv8tion.jda.api.interactions.components.selections.SelectOption;
1110
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;
@@ -32,10 +31,8 @@ public void onSlashEmojis(GuildSlashEvent event) {
3231
.build();
3332

3433
event.reply(messageData)
35-
// Since we reply to a slash command, we need to retrieve the message back
36-
.flatMap(InteractionHook::retrieveOriginal)
3734
// This emoji's name is slightly different as fields can't start with digits
38-
.flatMap(message -> message.addReaction(Emojis.HUNDRED_POINTS))
35+
.flatMap(hook -> hook.getCallbackResponse().getMessage().addReaction(Emojis.HUNDRED_POINTS))
3936
.queue();
4037
}
4138
}

src/test/kotlin/io/github/freya022/botcommands/test/commands/slash/SlashNewButtons.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ class SlashNewButtons(
118118

119119
buttons.group(secondButton).ephemeral {
120120
timeout(15.minutes) {
121-
event.hook.retrieveOriginal()
122-
.flatMap { event.hook.editOriginalComponents(it.components.asDisabled()) }
123-
.queue()
121+
val newComponents = event.hook.callbackResponse.message!!.components.asDisabled()
122+
event.hook.editOriginalComponents(newComponents).queue()
124123
}
125124
}
126125
return firstButton

src/test/kotlin/io/github/freya022/botcommands/test/commands/slash/SlashNewSelects.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ class SlashNewSelects(
9999

100100
selectMenus.group(firstSelect).ephemeral {
101101
timeout(15.seconds) {
102-
event.hook.retrieveOriginal()
103-
.flatMap { event.hook.editOriginalComponents(it.components.asDisabled()) }
104-
.queue()
102+
val newComponents = event.hook.callbackResponse.message!!.components.asDisabled()
103+
event.hook.editOriginalComponents(newComponents).queue()
105104
}
106105
}
107106
return firstSelect

0 commit comments

Comments
 (0)