From dc05cdc995683b3280ff3a19c4a691cee3a4eb35 Mon Sep 17 00:00:00 2001 From: Aneesh Kadiyala <143342960+ARandomDev99@users.noreply.github.com> Date: Fri, 22 Dec 2023 23:07:47 +0530 Subject: [PATCH] Switch to `i64` in methods associated with `CreateCommandOption` (#2668) This commit: - switches from `u64` to `i64` in `CreateCommandOption::min_int_value` and `CreateCommandOption::max_int_value` to accommodate negative integers in Discord's integer range (between -2^53 and 2^53). Values outside this range will cause Discord's API to return an error. - switches from `i32` to `i64` in `CreateCommandOption::add_int_choice` and `CreateCommandOption::add_int_choice_localized` to accommodate Discord's complete integer range (between -2^53 and 2^53). Values outside this range will cause Discord's API to return an error. --- src/builder/create_command.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/builder/create_command.rs b/src/builder/create_command.rs index 0af98c50479..8f625f6c403 100644 --- a/src/builder/create_command.rs +++ b/src/builder/create_command.rs @@ -112,7 +112,7 @@ impl CreateCommandOption { /// /// **Note**: There can be no more than 25 choices set. Name must be between 1 and 100 /// characters. Value must be between -2^53 and 2^53. - pub fn add_int_choice(self, name: impl Into, value: i32) -> Self { + pub fn add_int_choice(self, name: impl Into, value: i64) -> Self { self.add_choice(CommandOptionChoice { name: name.into().into(), value: Value::from(value), @@ -124,7 +124,7 @@ impl CreateCommandOption { pub fn add_int_choice_localized( self, name: impl Into, - value: i32, + value: i64, locales: impl IntoIterator, impl Into)>, ) -> Self { self.add_choice(CommandOptionChoice { @@ -246,13 +246,13 @@ impl CreateCommandOption { } /// Sets the minimum permitted value for this integer option - pub fn min_int_value(mut self, value: u64) -> Self { + pub fn min_int_value(mut self, value: i64) -> Self { self.0.min_value = Some(value.into()); self } /// Sets the maximum permitted value for this integer option - pub fn max_int_value(mut self, value: u64) -> Self { + pub fn max_int_value(mut self, value: i64) -> Self { self.0.max_value = Some(value.into()); self }