Skip to content

Commit 1507cc1

Browse files
committed
refactor: handle roleString from early on
Get a reference of `roleString` as early as possible, and be more explicit about which argument we want to get from the arguments list. At any given point (think, a future update to some library like JDA), the list we are getting all of our arguments from could end up looking from this: [1192015871509315, "Role String"] to: [1192015871509315, "Role String", 24] Therefore, making `args.getLast()` entirely obsolete. Being more explicit about the argument number we would like to get reduces the chances of something like this happening. Suggested-by: Zabuzard <[email protected]> Signed-off-by: Chris Sdogkos <[email protected]>
1 parent 643d600 commit 1507cc1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

application/src/main/java/org/togetherjava/tjbot/features/roleapplication/RoleApplicationHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ protected void sendApplicationResult(final ModalInteractionEvent event, List<Str
7171
return;
7272
}
7373

74+
String roleString = args.get(1);
75+
7476
Optional<TextChannel> applicationChannel = getApplicationChannel(guild);
7577
if (applicationChannel.isEmpty()) {
7678
return;
@@ -83,7 +85,6 @@ protected void sendApplicationResult(final ModalInteractionEvent event, List<Str
8385
.setFooter("Submitted at")
8486
.setTimestamp(Instant.now());
8587

86-
String roleString = args.getLast();
8788
MessageEmbed.Field roleField = new MessageEmbed.Field("Role", roleString, false);
8889
embed.addField(roleField);
8990

0 commit comments

Comments
 (0)