diff --git a/README.md b/README.md index 9487339..db8c81b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ To install `twilight-interactions`, add the following to your `Cargo.toml`: ```toml [dependencies] -twilight-interactions = "0.14" +twilight-interactions = "0.15" ``` The crate's major version follows the version of the official twilight crates. diff --git a/twilight-interactions-derive/Cargo.toml b/twilight-interactions-derive/Cargo.toml index 719edf9..9424ab6 100644 --- a/twilight-interactions-derive/Cargo.toml +++ b/twilight-interactions-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "twilight-interactions-derive" -version = "0.14.4" +version = "0.15.0" description = "Macros and utilities to make Discord Interactions easy to use with Twilight." categories = ["parsing", "config", "asynchronous"] keywords = ["twilight", "discord", "slash-command"] diff --git a/twilight-interactions-derive/src/command/model/parse.rs b/twilight-interactions-derive/src/command/model/parse.rs index 520d46e..1165878 100644 --- a/twilight-interactions-derive/src/command/model/parse.rs +++ b/twilight-interactions-derive/src/command/model/parse.rs @@ -301,7 +301,7 @@ impl ChannelType { "guild_forum" => Ok(Self::GuildForum), invalid => Err(Error::new( span, - format!("`{}` is not a valid channel type", invalid), + format!("`{invalid}` is not a valid channel type"), )), } } diff --git a/twilight-interactions-derive/src/option/create_option.rs b/twilight-interactions-derive/src/option/create_option.rs index c87aa2c..15b115c 100644 --- a/twilight-interactions-derive/src/option/create_option.rs +++ b/twilight-interactions-derive/src/option/create_option.rs @@ -80,13 +80,12 @@ fn choice_variant(variant: &ParsedVariant) -> TokenStream { }; quote! { - choices.push(::twilight_model::application::command::CommandOptionChoice::#type_path( - ::twilight_model::application::command::CommandOptionChoiceData { + choices.push( + ::twilight_model::application::command::CommandOptionChoice { name: ::std::convert::From::from(#name), name_localizations: #name_localizations, - value: #value, - } - )); + value: ::twilight_model::application::command::CommandOptionChoiceValue::#type_path(#value), + }); } } diff --git a/twilight-interactions-derive/src/parse.rs b/twilight-interactions-derive/src/parse.rs index 24cb43c..8e6713a 100644 --- a/twilight-interactions-derive/src/parse.rs +++ b/twilight-interactions-derive/src/parse.rs @@ -123,7 +123,7 @@ impl NamedAttrs { None => { return Err(Error::new( inner.path.span(), - format!("Invalid parameter name (expected {})", expected), + format!("Invalid parameter name (expected {expected})"), )) } }; @@ -132,7 +132,7 @@ impl NamedAttrs { if !expected.contains(&*key) { return Err(Error::new( inner.path.span(), - format!("Invalid parameter name (expected {})", expected), + format!("Invalid parameter name (expected {expected})"), )); } @@ -228,20 +228,14 @@ pub fn parse_name(val: &AttrValue) -> Result { if !char.is_alphanumeric() && char != '-' && char != '_' { return Err(Error::new( span, - format!( - "Name must only contain word characters, found invalid character `{}`", - char - ), + format!("Name must only contain word characters, found invalid character `{char}`"), )); } if char.to_lowercase().to_string() != char.to_string() { return Err(Error::new( span, - format!( - "Name must be in lowercase, found invalid character `{}`", - char - ), + format!("Name must be in lowercase, found invalid character `{char}`"), )); } } diff --git a/twilight-interactions/Cargo.toml b/twilight-interactions/Cargo.toml index fdfac1d..700cb28 100644 --- a/twilight-interactions/Cargo.toml +++ b/twilight-interactions/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "twilight-interactions" -version = "0.14.4" +version = "0.15.0" description = "Macros and utilities to make Discord Interactions easy to use with Twilight." categories = ["parsing", "config", "asynchronous"] keywords = ["twilight", "discord", "slash-command"] @@ -19,8 +19,8 @@ default = ["derive"] derive = ["twilight-interactions-derive"] [dependencies] -twilight-model = "0.14.1" -twilight-interactions-derive = { version = "=0.14.4", path = "../twilight-interactions-derive", optional = true } +twilight-model = "0.15.0" +twilight-interactions-derive = { version = "=0.15.0", path = "../twilight-interactions-derive", optional = true } [package.metadata.docs.rs] all-features = true diff --git a/twilight-interactions/src/error.rs b/twilight-interactions/src/error.rs index 205dd07..c583659 100644 --- a/twilight-interactions/src/error.rs +++ b/twilight-interactions/src/error.rs @@ -54,21 +54,21 @@ impl Display for ParseOptionError { match &self.kind { ParseOptionErrorType::InvalidType(ty) => write!(f, "invalid type, found {}", ty.kind()), ParseOptionErrorType::InvalidChoice(choice) => { - write!(f, "invalid choice value, found `{}`", choice) + write!(f, "invalid choice value, found `{choice}`") } ParseOptionErrorType::IntegerOutOfRange(val) => { - write!(f, "out of range integer, received `{}`", val) + write!(f, "out of range integer, received `{val}`") } ParseOptionErrorType::NumberOutOfRange(val) => { - write!(f, "out of range number, received `{}`", val) + write!(f, "out of range number, received `{val}`") } ParseOptionErrorType::StringLengthOutOfRange(val) => { - write!(f, "out of range string length, received `{}`", val) + write!(f, "out of range string length, received `{val}`") } ParseOptionErrorType::InvalidChannelType(kind) => { write!(f, "invalid channel type, received `{}`", kind.name()) } - ParseOptionErrorType::LookupFailed(id) => write!(f, "failed to resolve `{}`", id), + ParseOptionErrorType::LookupFailed(id) => write!(f, "failed to resolve `{id}`"), ParseOptionErrorType::UnknownField => write!(f, "unknown field"), ParseOptionErrorType::UnknownSubcommand => write!(f, "unknown subcommand"), ParseOptionErrorType::RequiredField => write!(f, "missing required field"), diff --git a/twilight-interactions/tests/choice_option.rs b/twilight-interactions/tests/choice_option.rs index 3bf36fc..ae02a6d 100644 --- a/twilight-interactions/tests/choice_option.rs +++ b/twilight-interactions/tests/choice_option.rs @@ -6,7 +6,7 @@ use twilight_interactions::command::{ }; use twilight_model::application::{ command::{ - CommandOption as TwilightCommandOption, CommandOptionChoice, CommandOptionChoiceData, + CommandOption as TwilightCommandOption, CommandOptionChoice, CommandOptionChoiceValue, CommandOptionType, }, interaction::application_command::CommandOptionValue, @@ -79,21 +79,21 @@ fn test_command_option_string() { autocomplete: Some(false), channel_types: None, choices: Some(vec![ - CommandOptionChoice::String(CommandOptionChoiceData { + CommandOptionChoice { name: "Dog".to_string(), name_localizations: Some(HashMap::from([("en".to_string(), "Dog".to_string())])), - value: "dog".to_string(), - }), - CommandOptionChoice::String(CommandOptionChoiceData { + value: CommandOptionChoiceValue::String("dog".to_string()), + }, + CommandOptionChoice { name: "Cat".to_string(), name_localizations: None, - value: "cat".to_string(), - }), - CommandOptionChoice::String(CommandOptionChoiceData { + value: CommandOptionChoiceValue::String("cat".to_string()), + }, + CommandOptionChoice { name: "Crab".to_string(), name_localizations: None, - value: "crab".to_string(), - }), + value: CommandOptionChoiceValue::String("crab".to_string()), + }, ]), description: "description".to_string(), description_localizations: None, @@ -144,21 +144,21 @@ fn test_command_option_integer() { autocomplete: Some(false), channel_types: None, choices: Some(vec![ - CommandOptionChoice::Integer(CommandOptionChoiceData { + CommandOptionChoice { name: "One".to_string(), name_localizations: None, - value: 1, - }), - CommandOptionChoice::Integer(CommandOptionChoiceData { + value: CommandOptionChoiceValue::Integer(1), + }, + CommandOptionChoice { name: "Two".to_string(), name_localizations: None, - value: 2, - }), - CommandOptionChoice::Integer(CommandOptionChoiceData { + value: CommandOptionChoiceValue::Integer(2), + }, + CommandOptionChoice { name: "Three".to_string(), name_localizations: None, - value: 3, - }), + value: CommandOptionChoiceValue::Integer(3), + }, ]), description: "description".to_string(), description_localizations: None, @@ -209,21 +209,21 @@ fn test_command_option_number() { autocomplete: Some(false), channel_types: None, choices: Some(vec![ - CommandOptionChoice::Number(CommandOptionChoiceData { + CommandOptionChoice { name: "One".to_string(), name_localizations: None, - value: 1.0, - }), - CommandOptionChoice::Number(CommandOptionChoiceData { + value: CommandOptionChoiceValue::Number(1.0), + }, + CommandOptionChoice { name: "Half".to_string(), name_localizations: None, - value: 0.5, - }), - CommandOptionChoice::Number(CommandOptionChoiceData { + value: CommandOptionChoiceValue::Number(0.5), + }, + CommandOptionChoice { name: "Quarter".to_string(), name_localizations: None, - value: 0.25, - }), + value: CommandOptionChoiceValue::Number(0.25), + }, ]), description: "description".to_string(), description_localizations: None, diff --git a/twilight-interactions/tests/command_model.rs b/twilight-interactions/tests/command_model.rs index 1f5f23a..185d120 100644 --- a/twilight-interactions/tests/command_model.rs +++ b/twilight-interactions/tests/command_model.rs @@ -5,7 +5,7 @@ use twilight_model::{ application::interaction::application_command::{ CommandDataOption, CommandInteractionDataResolved, CommandOptionValue, InteractionMember, }, - guild::Permissions, + guild::{MemberFlags, Permissions}, id::Id, user::User, util::Timestamp, @@ -62,6 +62,7 @@ fn test_command_model() { communication_disabled_until: None, pending: false, permissions: Permissions::empty(), + flags: MemberFlags::empty(), }; let user = User {