diff options
author | Marko Zajc <marko@zajc.eu.org> | 2022-07-03 17:34:31 +0200 |
---|---|---|
committer | Marko Zajc <marko@zajc.eu.org> | 2022-07-03 17:34:31 +0200 |
commit | 71722ae0047e8ff9a5052d951c19345d020fab04 (patch) | |
tree | b49212ef3fb6b317511ebbdc3067169a5f3b3c07 | |
parent | 114f85ce9fd4b32140406e38a92d26cfdd2e8e43 (diff) |
Fix a deadlock in confirm()
-rw-r--r-- | src/main/java/libot/core/entities/CommandContext.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/libot/core/entities/CommandContext.java b/src/main/java/libot/core/entities/CommandContext.java index 042e9bb..5357eb0 100644 --- a/src/main/java/libot/core/entities/CommandContext.java +++ b/src/main/java/libot/core/entities/CommandContext.java | |||
@@ -793,6 +793,7 @@ public class CommandContext { | |||
793 | 793 | ||
794 | // ===============* confirm *=============== | 794 | // ===============* confirm *=============== |
795 | 795 | ||
796 | @SuppressWarnings("null") | ||
796 | public boolean confirm(@Nonnull String message) { | 797 | public boolean confirm(@Nonnull String message) { |
797 | String useMessage = message; | 798 | String useMessage = message; |
798 | if (!hasChannelPermission(MESSAGE_ADD_REACTION)) | 799 | if (!hasChannelPermission(MESSAGE_ADD_REACTION)) |
@@ -801,12 +802,13 @@ public class CommandContext { | |||
801 | // because the stupid user denied/forgot to grant it | 802 | // because the stupid user denied/forgot to grant it |
802 | 803 | ||
803 | try { | 804 | try { |
804 | return reply(useMessage).thenApply(this::getConfirmation).get(); | 805 | return getConfirmation(reply(useMessage).get()); |
805 | } catch (ExecutionException | InterruptedException e) { // NOSONAR | 806 | } catch (ExecutionException | InterruptedException e) { // NOSONAR |
806 | throw asUnchecked(e); | 807 | throw asUnchecked(e); |
807 | } | 808 | } |
808 | } | 809 | } |
809 | 810 | ||
811 | @SuppressWarnings("null") | ||
810 | public boolean confirm(@Nonnull MessageEmbed embed) { | 812 | public boolean confirm(@Nonnull MessageEmbed embed) { |
811 | MessageEmbed useEmbed; | 813 | MessageEmbed useEmbed; |
812 | if (!canReact()) { // fallback ditto | 814 | if (!canReact()) { // fallback ditto |
@@ -823,7 +825,7 @@ public class CommandContext { | |||
823 | } | 825 | } |
824 | 826 | ||
825 | try { | 827 | try { |
826 | return reply(useEmbed).thenApply(this::getConfirmation).get(); | 828 | return getConfirmation(reply(useEmbed).get()); |
827 | } catch (ExecutionException | InterruptedException e) { // NOSONAR | 829 | } catch (ExecutionException | InterruptedException e) { // NOSONAR |
828 | throw asUnchecked(e); | 830 | throw asUnchecked(e); |
829 | } | 831 | } |