use correct name for resolving flags and params in codegen

This commit is contained in:
dusk 2025-10-11 05:49:01 +00:00
parent 42c9429953
commit ca9f25ff64
No known key found for this signature in database
2 changed files with 11 additions and 8 deletions

View file

@ -8,7 +8,7 @@ public partial class CommandTree
{ {
if (commands.Length == 0) if (commands.Length == 0)
{ {
await ctx.Reply($"No commands related to {subject} was found. For the full list of commands, see the website: <https://pluralkit.me/commands>"); await ctx.Reply($"No commands related to `{subject}` was found. For the full list of commands, see the website: <https://pluralkit.me/commands>");
return; return;
} }
@ -17,7 +17,7 @@ public partial class CommandTree
new MessageComponent() new MessageComponent()
{ {
Type = ComponentType.Text, Type = ComponentType.Text,
Content = $"Here is a list of commands related to {subject}:\n{commands}\nFor a full list of possible commands, see <https://pluralkit.me/commands>.", Content = $"Here is a list of commands related to `{subject}`:\n{commands}\nFor a full list of possible commands, see <https://pluralkit.me/commands>.",
} }
] ]
); );

View file

@ -45,8 +45,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
for param in &command_params { for param in &command_params {
writeln!( writeln!(
&mut command_params_init, &mut command_params_init,
r#"@{name} = await ctx.ParamResolve{extract_fn_name}("{name}"){throw_null},"#, r#"@{fieldName} = await ctx.ParamResolve{extract_fn_name}("{name}"){throw_null},"#,
name = param.name().replace("-", "_"), fieldName = param.name().replace("-", "_"),
name = param.name(),
extract_fn_name = get_param_param_ty(param.kind()), extract_fn_name = get_param_param_ty(param.kind()),
throw_null = param throw_null = param
.is_optional() .is_optional()
@ -59,15 +60,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if let Some(param) = flag.get_value() { if let Some(param) = flag.get_value() {
writeln!( writeln!(
&mut command_flags_init, &mut command_flags_init,
r#"@{name} = await ctx.FlagResolve{extract_fn_name}("{name}"),"#, r#"@{fieldName} = await ctx.FlagResolve{extract_fn_name}("{name}"),"#,
name = flag.get_name().replace("-", "_"), fieldName = flag.get_name().replace("-", "_"),
name = flag.get_name(),
extract_fn_name = get_param_param_ty(param.kind()), extract_fn_name = get_param_param_ty(param.kind()),
)?; )?;
} else { } else {
writeln!( writeln!(
&mut command_flags_init, &mut command_flags_init,
r#"@{name} = ctx.Parameters.HasFlag("{name}"),"#, r#"@{fieldName} = ctx.Parameters.HasFlag("{name}"),"#,
name = flag.get_name().replace("-", "_"), fieldName = flag.get_name().replace("-", "_"),
name = flag.get_name(),
)?; )?;
} }
} }