diff options
author | Marko Zajc <marko@zajc.eu.org> | 2023-02-18 14:38:49 +0100 |
---|---|---|
committer | Marko Zajc <marko@zajc.eu.org> | 2023-02-18 14:38:49 +0100 |
commit | f8a060433a655e983e5fc679f8800fd314926a7d (patch) | |
tree | ed639bd1f2e37fe75b51e3179ecd0d9fd9cff186 | |
parent | d0ecfe34132389f2f72ed7695abc43a0a7482b5d (diff) |
Resolve ambiguity with keepPrompt on confirm(f) overloads
-rw-r--r-- | src/main/java/libot/core/entities/CommandContext.java | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/main/java/libot/core/entities/CommandContext.java b/src/main/java/libot/core/entities/CommandContext.java index a729068..1678baf 100644 --- a/src/main/java/libot/core/entities/CommandContext.java +++ b/src/main/java/libot/core/entities/CommandContext.java | |||
@@ -794,11 +794,11 @@ public class CommandContext { | |||
794 | // ===============* confirm *=============== | 794 | // ===============* confirm *=============== |
795 | 795 | ||
796 | public boolean confirm(@Nonnull String message) { | 796 | public boolean confirm(@Nonnull String message) { |
797 | return confirm(message, false); | 797 | return confirm(false, message); |
798 | } | 798 | } |
799 | 799 | ||
800 | @SuppressWarnings("null") | 800 | @SuppressWarnings("null") |
801 | public boolean confirm(@Nonnull String message, boolean keepPrompt) { | 801 | public boolean confirm(boolean keepPrompt, @Nonnull String message) { |
802 | String useMessage = message; | 802 | String useMessage = message; |
803 | if (!hasChannelPermission(MESSAGE_ADD_REACTION)) | 803 | if (!hasChannelPermission(MESSAGE_ADD_REACTION)) |
804 | useMessage += "\n" + FORMAT_FALLBACK_ASK; | 804 | useMessage += "\n" + FORMAT_FALLBACK_ASK; |
@@ -806,18 +806,18 @@ public class CommandContext { | |||
806 | // because the stupid user denied/forgot to grant it | 806 | // because the stupid user denied/forgot to grant it |
807 | 807 | ||
808 | try { | 808 | try { |
809 | return getConfirmation(reply(useMessage).get(), false); | 809 | return getConfirmation(reply(useMessage).get(), keepPrompt); |
810 | } catch (ExecutionException | InterruptedException e) { // NOSONAR | 810 | } catch (ExecutionException | InterruptedException e) { // NOSONAR |
811 | throw asUnchecked(e); | 811 | throw asUnchecked(e); |
812 | } | 812 | } |
813 | } | 813 | } |
814 | 814 | ||
815 | public boolean confirm(@Nonnull MessageEmbed embed) { | 815 | public boolean confirm(@Nonnull MessageEmbed embed) { |
816 | return confirm(embed, false); | 816 | return confirm(false, embed); |
817 | } | 817 | } |
818 | 818 | ||
819 | @SuppressWarnings("null") | 819 | @SuppressWarnings("null") |
820 | public boolean confirm(@Nonnull MessageEmbed embed, boolean keepPrompt) { | 820 | public boolean confirm(boolean keepPrompt, @Nonnull MessageEmbed embed) { |
821 | MessageEmbed useEmbed; | 821 | MessageEmbed useEmbed; |
822 | if (!canReact()) { // fallback ditto | 822 | if (!canReact()) { // fallback ditto |
823 | var eb = new EmbedBuilder(embed); | 823 | var eb = new EmbedBuilder(embed); |
@@ -840,40 +840,40 @@ public class CommandContext { | |||
840 | } | 840 | } |
841 | 841 | ||
842 | public boolean confirm(@Nonnull EmbedBuilder builder) { | 842 | public boolean confirm(@Nonnull EmbedBuilder builder) { |
843 | return confirm(builder.build(), false); | 843 | return confirm(false, builder.build()); |
844 | } | 844 | } |
845 | 845 | ||
846 | public boolean confirm(@Nonnull EmbedBuilder builder, boolean keepPrompt) { | 846 | public boolean confirm(boolean keepPrompt, @Nonnull EmbedBuilder builder) { |
847 | return confirm(builder.build(), keepPrompt); | 847 | return confirm(keepPrompt, builder.build()); |
848 | } | 848 | } |
849 | 849 | ||
850 | public boolean confirm(@Nullable String title, @Nonnull String message, @Nullable String footer, | 850 | public boolean confirm(@Nullable String title, @Nonnull String message, @Nullable String footer, |
851 | @Nullable Color color) { | 851 | @Nullable Color color) { |
852 | return confirm(title, message, footer, color, false); | 852 | return confirm(false, title, message, footer, color); |
853 | } | 853 | } |
854 | 854 | ||
855 | public boolean confirm(@Nullable String title, @Nonnull String message, @Nullable String footer, | 855 | public boolean confirm(boolean keepPrompt, @Nullable String title, @Nonnull String message, |
856 | @Nullable Color color, boolean keepPrompt) { | 856 | @Nullable String footer, @Nullable Color color) { |
857 | EmbedBuilder builder = | 857 | EmbedBuilder builder = |
858 | new EmbedBuilder().setTitle(title).appendDescription(message).setFooter(footer, null).setColor(color); | 858 | new EmbedBuilder().setTitle(title).appendDescription(message).setFooter(footer, null).setColor(color); |
859 | 859 | ||
860 | return confirm(builder.build(), keepPrompt); | 860 | return confirm(keepPrompt, builder.build()); |
861 | } | 861 | } |
862 | 862 | ||
863 | public boolean confirm(@Nullable String title, @Nonnull String message, @Nullable Color color) { | 863 | public boolean confirm(@Nullable String title, @Nonnull String message, @Nullable Color color) { |
864 | return confirm(title, message, null, color, false); | 864 | return confirm(false, title, message, null, color); |
865 | } | 865 | } |
866 | 866 | ||
867 | public boolean confirm(@Nullable String title, @Nonnull String message, @Nullable Color color, boolean keepPrompt) { | 867 | public boolean confirm(boolean keepPrompt, @Nullable String title, @Nonnull String message, @Nullable Color color) { |
868 | return confirm(title, message, null, color, keepPrompt); | 868 | return confirm(keepPrompt, title, message, null, color); |
869 | } | 869 | } |
870 | 870 | ||
871 | public boolean confirm(@Nonnull String message, @Nullable Color color) { | 871 | public boolean confirm(@Nonnull String message, @Nullable Color color) { |
872 | return confirm(null, message, null, color, false); | 872 | return confirm(false, null, message, null, color); |
873 | } | 873 | } |
874 | 874 | ||
875 | public boolean confirm(@Nonnull String message, @Nullable Color color, boolean keepPrompt) { | 875 | public boolean confirm(boolean keepPrompt, @Nonnull String message, @Nullable Color color) { |
876 | return confirm(null, message, null, color, keepPrompt); | 876 | return confirm(keepPrompt, null, message, null, color); |
877 | } | 877 | } |
878 | 878 | ||
879 | // ===============* confirmf *=============== | 879 | // ===============* confirmf *=============== |
@@ -884,40 +884,40 @@ public class CommandContext { | |||
884 | } | 884 | } |
885 | 885 | ||
886 | @SuppressWarnings("null") | 886 | @SuppressWarnings("null") |
887 | public boolean confirmf(@Nonnull String messageFormat, boolean keepPrompt, @Nonnull Object... args) { | 887 | public boolean confirmf(boolean keepPrompt, @Nonnull String messageFormat, @Nonnull Object... args) { |
888 | return confirm(format(messageFormat, args), keepPrompt); | 888 | return confirm(keepPrompt, format(messageFormat, args)); |
889 | } | 889 | } |
890 | 890 | ||
891 | @SuppressWarnings("null") | 891 | @SuppressWarnings("null") |
892 | public boolean confirmf(@Nullable String title, @Nonnull String messageFormat, @Nullable String footer, | 892 | public boolean confirmf(@Nullable String title, @Nonnull String messageFormat, @Nullable String footer, |
893 | @Nullable Color color, @Nonnull Object... args) { | 893 | @Nullable Color color, @Nonnull Object... args) { |
894 | return confirm(title, format(messageFormat, args), footer, color); | 894 | return confirm(title, format(messageFormat, args), footer, color); |
895 | 895 | ||
896 | } | 896 | } |
897 | 897 | ||
898 | @SuppressWarnings("null") | 898 | @SuppressWarnings("null") |
899 | public boolean confirmf(@Nullable String title, @Nonnull String messageFormat, @Nullable String footer, | 899 | public boolean confirmf(boolean keepPrompt, @Nullable String title, @Nonnull String messageFormat, |
900 | boolean keepPrompt, @Nullable Color color, @Nonnull Object... args) { | 900 | @Nullable String footer, @Nullable Color color, @Nonnull Object... args) { |
901 | return confirm(title, format(messageFormat, args), footer, color, keepPrompt); | 901 | return confirm(keepPrompt, title, format(messageFormat, args), footer, color); |
902 | } | 902 | } |
903 | 903 | ||
904 | public boolean confirmf(@Nullable String title, @Nonnull String messageFormat, @Nullable Color color, | 904 | public boolean confirmf(@Nullable String title, @Nonnull String messageFormat, @Nullable Color color, |
905 | @Nonnull Object... args) { | 905 | @Nonnull Object... args) { |
906 | return confirmf(title, messageFormat, null, false, color, args); | 906 | return confirmf(false, title, messageFormat, null, color, args); |
907 | } | 907 | } |
908 | 908 | ||
909 | public boolean confirmf(@Nullable String title, @Nonnull String messageFormat, boolean keepPrompt, | 909 | public boolean confirmf(boolean keepPrompt, @Nullable String title, @Nonnull String messageFormat, |
910 | @Nullable Color color, @Nonnull Object... args) { | 910 | @Nullable Color color, @Nonnull Object... args) { |
911 | return confirmf(title, messageFormat, null, keepPrompt, color, args); | 911 | return confirmf(keepPrompt, title, messageFormat, null, color, args); |
912 | } | 912 | } |
913 | 913 | ||
914 | public boolean confirmf(@Nonnull String messageFormat, @Nullable Color color, @Nonnull Object... args) { | 914 | public boolean confirmf(@Nonnull String messageFormat, @Nullable Color color, @Nonnull Object... args) { |
915 | return confirmf(null, messageFormat, null, false, color, args); | 915 | return confirmf(false, null, messageFormat, null, color, args); |
916 | } | 916 | } |
917 | 917 | ||
918 | public boolean confirmf(@Nonnull String messageFormat, boolean keepPrompt, @Nullable Color color, | 918 | public boolean confirmf(boolean keepPrompt, @Nonnull String messageFormat, @Nullable Color color, |
919 | @Nonnull Object... args) { | 919 | @Nonnull Object... args) { |
920 | return confirmf(null, messageFormat, null, keepPrompt, color, args); | 920 | return confirmf(keepPrompt, null, messageFormat, null, color, args); |
921 | } | 921 | } |
922 | 922 | ||
923 | // ===============* askraw *=============== | 923 | // ===============* askraw *=============== |