|
26 | 26 | import net.dv8tion.jda.api.hooks.ListenerAdapter; |
27 | 27 | import net.dv8tion.jda.api.interactions.InteractionHook; |
28 | 28 | import net.dv8tion.jda.api.modals.Modal; |
| 29 | +import net.dv8tion.jda.api.requests.RestAction; |
29 | 30 | import org.comroid.annotations.Ignore; |
30 | 31 | import org.comroid.annotations.internal.Annotations; |
31 | 32 | import org.comroid.api.attr.Aliased; |
@@ -242,7 +243,8 @@ protected boolean checkOutOfContext(GenericInteractionCreateEvent event) { |
242 | 243 | public void clear() { |
243 | 244 | List<Message> ls = List.of(); |
244 | 245 | do { |
245 | | - if (!ls.isEmpty()) channel.deleteMessages(ls).complete(); |
| 246 | + if (ls.size() >= 2) channel.deleteMessages(ls).complete(); |
| 247 | + else ls.stream().map(Message::delete).forEach(RestAction::queue); |
246 | 248 | ls = channel.getHistory().retrievePast(100).complete(); |
247 | 249 | } while (!ls.isEmpty()); |
248 | 250 | } |
@@ -358,9 +360,10 @@ public void onButtonInteraction(@NotNull ButtonInteractionEvent event) { |
358 | 360 | event.deferReply().submit().thenCompose(hook -> { |
359 | 361 | if (checkOutOfContext(event)) return CompletableFuture.completedFuture(null); |
360 | 362 | event.replyModal(Modal.create(event.getComponentId(), event.getComponentId()) |
361 | | - .addComponents(Label.of("New Value", TextInput.create("newValue", TextInputStyle.SHORT) |
362 | | - .setPlaceholder(config.get(event.getComponentId().split("\\.")).asString()) |
363 | | - .build())) |
| 363 | + .addComponents(Label.of("New Value", |
| 364 | + TextInput.create("newValue", TextInputStyle.SHORT) |
| 365 | + .setPlaceholder(config.get(event.getComponentId().split("\\.")).asString()) |
| 366 | + .build())) |
364 | 367 | .build()).queue(); |
365 | 368 | return hook.sendMessage("Done!").setEphemeral(false).submit(); |
366 | 369 | }).exceptionally(Debug.exceptionLogger("Internal error when handling interaction")); |
|
0 commit comments