build slash commands at launch

This commit is contained in:
2021-06-11 10:39:32 +01:00
parent 1286f5f50e
commit 1f61b72cc5
6 changed files with 63 additions and 21 deletions

View File

@ -339,9 +339,6 @@ impl AttributeOption for Arg {
"required" => {
arg.required = value.to_bool();
}
"default" => {
arg.default = value.to_bool();
}
"kind" => arg.kind = ApplicationCommandOptionType::from_str(value.to_str()),
_ => {
return Err(Error::new(key.span(), "unexpected attribute"));

View File

@ -119,7 +119,6 @@ pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
description,
kind,
required,
default,
} = arg;
let an = n.with_suffix(name.as_str()).with_suffix(ARG);
@ -130,9 +129,8 @@ pub fn command(attr: TokenStream, input: TokenStream) -> TokenStream {
pub static #an: #arg_path = #arg_path {
name: #name,
description: #description,
required: #required,
default: #default,
kind: #kind,
required: #required,
};
}
})

View File

@ -273,7 +273,6 @@ pub(crate) struct Arg {
pub description: String,
pub kind: ApplicationCommandOptionType,
pub required: bool,
pub default: bool,
}
impl Default for Arg {
@ -283,7 +282,6 @@ impl Default for Arg {
description: String::new(),
kind: ApplicationCommandOptionType::String,
required: false,
default: false,
}
}
}
@ -291,7 +289,7 @@ impl Default for Arg {
#[derive(Debug, Default)]
pub(crate) struct Options {
pub aliases: Vec<String>,
pub description: AsOption<String>,
pub description: String,
pub usage: AsOption<String>,
pub examples: Vec<String>,
pub required_permissions: PermissionLevel,

View File

@ -221,13 +221,11 @@ pub fn rename_attributes(attributes: &mut Vec<Attribute>, name: &str, target: &s
}
}
pub fn append_line(desc: &mut AsOption<String>, mut line: String) {
pub fn append_line(desc: &mut String, mut line: String) {
if line.starts_with(' ') {
line.remove(0);
}
let desc = desc.0.get_or_insert_with(String::default);
match line.rfind("\\$") {
Some(i) => {
desc.push_str(line[..i].trim_end());