1414import net .javadiscord .javabot .Bot ;
1515import org .jetbrains .annotations .NotNull ;
1616
17+ import javax .annotation .CheckReturnValue ;
1718import javax .annotation .Nullable ;
1819import java .awt .*;
1920import java .time .Instant ;
@@ -29,84 +30,104 @@ public final class Responses {
2930 private Responses () {
3031 }
3132
33+ @ CheckReturnValue
3234 public static @ NotNull ReplyCallbackAction success (CommandInteraction event , String title , String message , Object ... args ) {
3335 return reply (event , title , String .format (message , args ), Type .SUCCESS .getColor (), true );
3436 }
3537
38+ @ CheckReturnValue
3639 public static @ NotNull WebhookMessageAction <Message > success (InteractionHook hook , String title , String message , Object ... args ) {
3740 return reply (hook , title , String .format (message , args ), Type .SUCCESS .getColor (), true );
3841 }
3942
43+ @ CheckReturnValue
4044 public static @ NotNull ReplyCallbackAction info (CommandInteraction event , String title , String message , Object ... args ) {
4145 return reply (event , title , String .format (message , args ), Type .INFO .getColor (), true );
4246 }
4347
48+ @ CheckReturnValue
4449 public static @ NotNull WebhookMessageAction <Message > info (InteractionHook hook , String title , String message , Object ... args ) {
4550 return reply (hook , title , String .format (message , args ), Type .INFO .getColor (), true );
4651 }
4752
53+ @ CheckReturnValue
4854 public static @ NotNull ReplyCallbackAction error (CommandInteraction event , String message , Object ... args ) {
4955 return reply (event , "An Error Occurred" , String .format (message , args ), Type .ERROR .getColor (), true );
5056 }
5157
58+ @ CheckReturnValue
5259 public static @ NotNull WebhookMessageAction <Message > error (InteractionHook hook , String message , Object ... args ) {
5360 return reply (hook , "An Error Occurred" , String .format (message , args ), Type .ERROR .getColor (), true );
5461 }
5562
63+ @ CheckReturnValue
5664 public static @ NotNull ReplyCallbackAction warning (CommandInteraction event , String message , Object ... args ) {
5765 return warning (event , null , String .format (message , args ));
5866 }
5967
68+ @ CheckReturnValue
6069 public static @ NotNull WebhookMessageAction <Message > warning (InteractionHook hook , String message , Object ... args ) {
6170 return warning (hook , null , String .format (message , args ));
6271 }
6372
73+ @ CheckReturnValue
6474 public static @ NotNull ReplyCallbackAction warning (CommandInteraction event , String title , String message , Object ... args ) {
6575 return reply (event , title , String .format (message , args ), Type .WARN .getColor (), true );
6676 }
6777
78+ @ CheckReturnValue
6879 public static @ NotNull WebhookMessageAction <Message > warning (InteractionHook hook , String title , String message , Object ... args ) {
6980 return reply (hook , title , String .format (message , args ), Type .WARN .getColor (), true );
7081 }
7182
83+ @ CheckReturnValue
7284 public static @ NotNull ReplyCallbackAction replyMissingArguments (CommandInteraction event ) {
7385 return error (event , "Missing required arguments." );
7486 }
7587
88+ @ CheckReturnValue
7689 public static @ NotNull WebhookMessageAction <Message > replyMissingArguments (InteractionHook hook ) {
7790 return error (hook , "Missing required arguments." );
7891 }
7992
93+ @ CheckReturnValue
8094 public static @ NotNull ReplyCallbackAction replyGuildOnly (CommandInteraction event ) {
8195 return error (event , "This command may only be used inside servers." );
8296 }
8397
98+ @ CheckReturnValue
8499 public static @ NotNull WebhookMessageAction <Message > replyGuildOnly (InteractionHook hook ) {
85100 return error (hook , "This command may only be used inside servers." );
86101 }
87102
103+ @ CheckReturnValue
88104 public static @ NotNull ReplyCallbackAction replyInsufficientPermissions (CommandInteraction event , Permission ... permissions ) {
89105 return error (event , "I am missing one or more permissions in order to execute this action. (%s)" ,
90106 Arrays .stream (permissions ).map (p -> MarkdownUtil .monospace (p .getName ())).collect (Collectors .joining (", " )));
91107 }
92108
109+ @ CheckReturnValue
93110 public static @ NotNull WebhookMessageAction <Message > replyInsufficientPermissions (InteractionHook hook , Permission ... permissions ) {
94111 return error (hook , "I am missing one or more permissions in order to execute this action. (%s)" ,
95112 Arrays .stream (permissions ).map (p -> MarkdownUtil .monospace (p .getName ())).collect (Collectors .joining (", " )));
96113 }
97114
115+ @ CheckReturnValue
98116 public static @ NotNull ReplyCallbackAction replyMissingMember (CommandInteraction event ) {
99117 return error (event , "The provided user **must** be a member of this server. Please try again." );
100118 }
101119
120+ @ CheckReturnValue
102121 public static @ NotNull ReplyCallbackAction replyCannotInteract (CommandInteraction event , @ NotNull IMentionable mentionable ) {
103122 return error (event , "I am missing permissions in order to interact with that. (%s)" , mentionable .getAsMention ());
104123 }
105124
125+ @ CheckReturnValue
106126 public static @ NotNull ReplyCallbackAction replyStaffOnly (CommandInteraction event , Guild guild ) {
107127 return error (event , "This command may only be used by staff members. (%s)" , Bot .getConfig ().get (guild ).getModerationConfig ().getStaffRole ().getAsMention ());
108128 }
109129
130+ @ CheckReturnValue
110131 public static @ NotNull ReplyCallbackAction replyAdminOnly (CommandInteraction event , Guild guild ) {
111132 return error (event , "This command may only be used by admins. (%s)" , Bot .getConfig ().get (guild ).getModerationConfig ().getAdminRole ().getAsMention ());
112133 }
@@ -121,6 +142,7 @@ private Responses() {
121142 * @param ephemeral Whether the message should be ephemeral.
122143 * @return The reply action.
123144 */
145+ @ CheckReturnValue
124146 private static @ NotNull ReplyCallbackAction reply (@ NotNull CommandInteraction event , @ Nullable String title , String message , Color color , boolean ephemeral ) {
125147 return event .replyEmbeds (buildEmbed (title , message , color )).setEphemeral (ephemeral );
126148 }
@@ -135,10 +157,12 @@ private Responses() {
135157 * @param ephemeral Whether the message should be ephemeral.
136158 * @return The webhook message action.
137159 */
160+ @ CheckReturnValue
138161 private static @ NotNull WebhookMessageAction <Message > reply (@ NotNull InteractionHook hook , @ Nullable String title , String message , Color color , boolean ephemeral ) {
139162 return hook .sendMessageEmbeds (buildEmbed (title , message , color )).setEphemeral (ephemeral );
140163 }
141164
165+ @ CheckReturnValue
142166 private static @ NotNull MessageEmbed buildEmbed (@ Nullable String title , String message , Color color ) {
143167 EmbedBuilder embedBuilder = new EmbedBuilder ()
144168 .setTimestamp (Instant .now ())
0 commit comments