Skip to content

Commit

Permalink
GH-364 Fix JDA description resolving. (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rollczi authored Jan 23, 2024
1 parent 3d7a185 commit 25a1592
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

class JDACommandTranslator {

private static final String DESCRIPTION_DEFAULT = "none";

private final WrapperRegistry wrapperRegistry;

private final Map<Class<?>, JDAType<?>> jdaSupportedTypes = new HashMap<>();
Expand Down Expand Up @@ -132,13 +134,20 @@ <SENDER> JDALiteCommand translate(
}

private String getDescription(MetaHolder holder) {
String joined = String.join(", ", holder.meta().get(Meta.DESCRIPTION));
List<List<String>> descriptions = holder.metaCollector().collect(Meta.DESCRIPTION);

if (descriptions.isEmpty()) {
return DESCRIPTION_DEFAULT; // Discord doesn't allow empty description
}

List<String> descriptionList = descriptions.get(0);
String description = String.join(", ", descriptionList);

if (joined.isEmpty()) {
return "none"; // Discord doesn't allow empty description
if (description.isEmpty()) {
return DESCRIPTION_DEFAULT; // Discord doesn't allow empty description
}

return joined;
return description;
}

private List<Permission> getPermissions(MetaHolder holder) {
Expand Down

0 comments on commit 25a1592

Please sign in to comment.