Skip to content

Commit a018503

Browse files
committed
Delete EmptyRestAction
This has the problem of not fully conforming to the contract of RestAction and therefore risking unspecified behavior. The one use of this is rewritten to use normal RestAction semantics.
1 parent f72765b commit a018503

File tree

2 files changed

+8
-83
lines changed

2 files changed

+8
-83
lines changed

src/core/java/com/mcmoddev/mmdbot/core/commands/CommandUpserter.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.jagrosh.jdautilities.command.CommandClient;
2424
import com.jagrosh.jdautilities.command.ContextMenu;
2525
import com.jagrosh.jdautilities.command.SlashCommand;
26-
import com.mcmoddev.mmdbot.core.util.EmptyRestAction;
2726
import com.mcmoddev.mmdbot.core.util.config.SnowflakeValue;
2827
import lombok.NonNull;
2928
import net.dv8tion.jda.api.JDA;
@@ -140,12 +139,14 @@ public void upsertCommands(@NonNull final JDA jda) {
140139
final var guild = guildId.resolve(jda::getGuildById);
141140
if (guild != null) {
142141
// Guild still specified? Then remove guild commands
143-
guild.retrieveCommands()
144-
.flatMap(commands -> commands.isEmpty() ? EmptyRestAction.empty() : RestAction.allOf(commands.stream()
145-
.map(Command::getIdLong)
146-
.map(guild::deleteCommandById)
147-
.toList()))
148-
.queue();
142+
guild.retrieveCommands().queue(commands -> {
143+
if (!commands.isEmpty()) {
144+
RestAction.allOf(commands.stream()
145+
.map(Command::getIdLong)
146+
.map(guild::deleteCommandById)
147+
.toList()).queue();
148+
}
149+
});
149150
}
150151
}
151152
jda.retrieveCommands().queue(commands -> {

src/core/java/com/mcmoddev/mmdbot/core/util/EmptyRestAction.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)