Skip to content

Commit 6e2e264

Browse files
committed
Fix ticket category select values
1 parent b0da474 commit 6e2e264

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ All notable changes to ZDiscord are documented here.
4343
- Ticket setup now uses the guided `/setup` wizard only and posts a ticket-specific setup flow.
4444
- Ticket creation ignores placeholder support-role IDs instead of aborting channel creation.
4545
- Setup and follow buttons use real emoji instead of Discord shortcode text.
46+
- Ticket panel dropdown values now submit category IDs instead of display labels.
4647
- `/panel` no longer crashes in thread or forum channels.
4748
- `UpdateChecker` Discord announcement retries on failure.
4849

src/main/java/dev/demonz/zdiscord/modules/TicketModule.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,17 @@ public TicketCategory getCategory(String id) {
226226
if (id == null) {
227227
return null;
228228
}
229-
return getCategories().get(id);
229+
Map<String, TicketCategory> cats = getCategories();
230+
TicketCategory direct = cats.get(id);
231+
if (direct != null) {
232+
return direct;
233+
}
234+
for (TicketCategory category : cats.values()) {
235+
if (id.equals(category.label) || id.equals(displayLabel(category))) {
236+
return category;
237+
}
238+
}
239+
return null;
230240
}
231241

232242
public String defaultCategoryId() {
@@ -421,12 +431,11 @@ public void postPanel(TextChannel channel) {
421431
.setMinValues(1)
422432
.setMaxValues(1);
423433
for (TicketCategory c : cats.values()) {
424-
String label = c.emoji.isEmpty() ? c.label
425-
: (c.emoji + " " + c.label);
434+
String label = displayLabel(c);
426435
String desc = c.description != null && c.description.length() > 100
427436
? c.description.substring(0, 97) + "..."
428437
: (c.description == null ? "" : c.description);
429-
menu.addOption(c.id, label, desc);
438+
menu.addOption(label, c.id, desc);
430439
}
431440

432441
List<net.dv8tion.jda.api.interactions.components.LayoutComponent> rows = new ArrayList<>();
@@ -495,4 +504,10 @@ public List<UUID> getOpenTicketCreators() {
495504
public static boolean isUsableSnowflake(String value) {
496505
return value != null && value.matches(SNOWFLAKE_PATTERN);
497506
}
507+
508+
private static String displayLabel(TicketCategory category) {
509+
return category.emoji.isEmpty()
510+
? category.label
511+
: category.emoji + " " + category.label;
512+
}
498513
}

0 commit comments

Comments
 (0)