@@ -65,6 +65,7 @@ public class ApplicationCreateCommand extends SlashCommandAdapter {
65
65
"What makes you a valuable addition to the team? 😎" ;
66
66
private static final int OPTIONAL_ROLES_AMOUNT = 5 ;
67
67
private static final String ROLE_COMPONENT_ID_HEADER = "application-create" ;
68
+ private static final String VALUE_DELIMITER = "_" ;
68
69
69
70
private final Cache <Member , OffsetDateTime > applicationSubmitCooldown ;
70
71
private final Predicate <String > applicationChannelPattern ;
@@ -101,13 +102,19 @@ private void generateRoleOptions(SlashCommandData data) {
101
102
IntStream .range (0 , OPTIONAL_ROLES_AMOUNT ).forEach (index -> {
102
103
int renderNumber = index + 1 ;
103
104
104
- data .addOption (OptionType .STRING , "title" + renderNumber , "The title of the role" );
105
- data .addOption (OptionType .STRING , "description" + renderNumber ,
105
+ data .addOption (OptionType .STRING , generateOptionId ("title" , renderNumber ),
106
+ "The title of the role" );
107
+ data .addOption (OptionType .STRING , generateOptionId ("description" , renderNumber ),
106
108
"The description of the role" );
107
- data .addOption (OptionType .STRING , "emoji" + renderNumber , "The emoji of the role" );
109
+ data .addOption (OptionType .STRING , generateOptionId ("emoji" , renderNumber ),
110
+ "The emoji of the role" );
108
111
});
109
112
}
110
113
114
+ private static String generateOptionId (String name , int id ) {
115
+ return "%s%s%d" .formatted (name , VALUE_DELIMITER , id );
116
+ }
117
+
111
118
@ Override
112
119
public void onSlashCommand (SlashCommandInteractionEvent event ) {
113
120
if (!handleHasPermissions (event )) {
@@ -197,11 +204,11 @@ public void onStringSelectSelection(StringSelectInteractionEvent event, List<Str
197
204
* @return the amount of roles with missing data
198
205
*/
199
206
private static long getIncorrectRoleArgsCount (final List <OptionMapping > args ) {
200
- final Map <Character , Integer > frequencyMap = new HashMap <>();
207
+ final Map <String , Integer > frequencyMap = new HashMap <>();
201
208
202
209
args .stream ()
203
210
.map (OptionMapping ::getName )
204
- .map (name -> name .charAt ( name . length () - 1 ) )
211
+ .map (name -> name .split ( VALUE_DELIMITER )[ 1 ] )
205
212
.forEach (number -> frequencyMap .merge (number , 1 , Integer ::sum ));
206
213
207
214
return frequencyMap .values ().stream ().filter (value -> value != 3 ).count ();
@@ -215,12 +222,12 @@ private static long getIncorrectRoleArgsCount(final List<OptionMapping> args) {
215
222
*/
216
223
private void addRolesToMenu (StringSelectMenu .Builder menuBuilder ,
217
224
final List <OptionMapping > args ) {
218
- final Map <Character , MenuRole > roles = new HashMap <>();
225
+ final Map <String , MenuRole > roles = new HashMap <>();
219
226
220
227
args .forEach (arg -> {
221
228
final String name = arg .getName ();
222
229
final String argValue = arg .getAsString ();
223
- final char roleId = name .charAt ( name . length () - 1 ) ;
230
+ final String roleId = name .split ( VALUE_DELIMITER )[ 1 ] ;
224
231
MenuRole role = roles .computeIfAbsent (roleId , k -> new MenuRole ());
225
232
226
233
if (name .startsWith ("title" )) {
0 commit comments