Skip to content

Commit

Permalink
fix: use component name as description fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Citymonstret committed Jan 14, 2024
1 parent 3612320 commit 8e1bb7d
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,16 @@ public <T extends Number, P extends ArgumentParser<C, T>> void registerRangeMapp
}
}

final String description;
if (component.description().isEmpty()) {
description = component.name();
} else {
description = component.description().textDescription();
}

return DiscordCommand.<C>builder()
.name(component.name())
.description(node.component().description().textDescription())
.description(description)
.addAllOptions(options)
.build();
}
Expand All @@ -156,6 +163,13 @@ public <T extends Number, P extends ArgumentParser<C, T>> void registerRangeMapp
private @NonNull DiscordOption<C> createOption(final @NonNull CommandNode<C> node) {
final CommandComponent<C> component = node.component();

final String description;
if (component.description().isEmpty()) {
description = component.name();
} else {
description = component.description().textDescription();
}

if (component.type() == CommandComponent.ComponentType.LITERAL) {
// We need to determine whether to flatten the children into a sub-command
// or whether to recursively extract the arguments.
Expand All @@ -182,7 +196,7 @@ public <T extends Number, P extends ArgumentParser<C, T>> void registerRangeMapp

return ImmutableSubCommand.<C>builder()
.name(component.name())
.description(component.description().textDescription())
.description(description)
.addAllOptions(children)
.build();
}
Expand All @@ -198,7 +212,8 @@ public <T extends Number, P extends ArgumentParser<C, T>> void registerRangeMapp
autoComplete = false;
}

return ImmutableVariable.<Object>builder().name(component.name()).description(component.description().textDescription())
return ImmutableVariable.<Object>builder().name(component.name())
.description(description)
.type(optionType)
.required(component.required())
.autocomplete(autoComplete)
Expand Down

0 comments on commit 8e1bb7d

Please sign in to comment.