Skip to content

Commit

Permalink
fix modal dispatching
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaktushose committed Jan 25, 2024
1 parent e6d754f commit 42f9329
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void onEvent(Context context) {
context.setRuntime(runtime);
List<Object> arguments = new ArrayList<>();
arguments.add(new ModalEvent(context));
arguments.addAll(event.getValues().stream().map(ModalMapping::getAsString).collect(Collectors.toSet()));
arguments.addAll(event.getValues().stream().map(ModalMapping::getAsString).collect(Collectors.toList()));
modal.getMethod().invoke(runtime.getInstance(), arguments.toArray());
} catch (Exception exception) {
log.error("Modal execution failed!", exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.kaktushose.jda.commands.dispatching.interactions.commands.SlashCommandContext;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent;
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
import net.dv8tion.jda.api.interactions.callbacks.IMessageEditCallback;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
Expand Down Expand Up @@ -216,6 +217,12 @@ private void queueEdit() {
queueReply();
return;
}
if (event instanceof ModalInteractionEvent) {
if (((ModalInteractionEvent) event).getMessage() == null) {
queueReply();
return;
}
}
if (!event.isAcknowledged()) {
callback.deferEdit().queue();
}
Expand Down

0 comments on commit 42f9329

Please sign in to comment.