|
37 | 37 | import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; |
38 | 38 | import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData; |
39 | 39 | import net.dv8tion.jda.api.requests.RestAction; |
40 | | -import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction; |
41 | 40 | import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; |
42 | 41 | import net.dv8tion.jda.api.utils.messages.MessageCreateData; |
43 | 42 | import net.dv8tion.jda.api.utils.messages.MessageEditBuilder; |
|
52 | 51 | import org.comroid.api.data.seri.type.StandardValueType; |
53 | 52 | import org.comroid.api.data.seri.type.ValueType; |
54 | 53 | import org.comroid.api.func.ext.Wrap; |
| 54 | +import org.comroid.api.func.util.Debug; |
55 | 55 | import org.comroid.api.func.util.Event; |
56 | 56 | import org.comroid.api.tree.UncheckedCloseable; |
57 | 57 | import org.comroid.commands.impl.AbstractCommandAdapter; |
@@ -266,17 +266,17 @@ public void handleResponse(CommandUsage cmd, @NotNull Object response, Object... |
266 | 266 | final var e = of(args).flatMap(cast(SlashCommandInteractionEvent.class)).findAny().orElseThrow(); |
267 | 267 | final var user = of(args).flatMap(cast(User.class)).findAny().orElseThrow(); |
268 | 268 | var ephemeral = cmd.getStackTrace().peek().getAttribute().privacy() != CommandPrivacyLevel.PUBLIC; |
| 269 | + |
269 | 270 | if (response instanceof CompletableFuture) e.deferReply() |
270 | 271 | .setEphemeral(ephemeral) |
271 | 272 | .submit() |
272 | 273 | .thenCombine(((CompletableFuture<?>) response), |
273 | 274 | (hook, resp) -> handleResponse(msg -> hook.sendMessage(msg).submit(), user, resp)) |
274 | 275 | .thenCompose(identity()) |
275 | | - .exceptionally(Polyfill.exceptionLogger()); |
276 | | - else { |
277 | | - ReplyCallbackAction req; |
278 | | - handleResponse(msg -> e.reply(msg).setEphemeral(ephemeral).submit(), user, response); |
279 | | - } |
| 276 | + .exceptionally(Debug.exceptionLogger("Could not defer reply to command")); |
| 277 | + else handleResponse(msg -> e.reply(msg).setEphemeral(ephemeral).submit(), |
| 278 | + user, |
| 279 | + response).exceptionally(Debug.exceptionLogger("Could not reply to command")); |
280 | 280 | } |
281 | 281 |
|
282 | 282 | @Override |
|
0 commit comments