From bea3b3bb750f7d97880a0116bb5fbd716039395c Mon Sep 17 00:00:00 2001 From: Aneesh Kadiyala <143342960+ARandomDev99@users.noreply.github.com> Date: Thu, 21 Dec 2023 22:04:51 +0530 Subject: [PATCH] Switch to i64 in methods associated with CreateCommandOption This commit: - switched from u64 to i64 in CreateCommandOption::min_int_value and CreateCommandOption::max_int_value to accomodate 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. - switched from i32 to i64 in CreateCommandOption::add_int_choice and CreateCommandOption::add_int_choice_localized to accomodate 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 ed3a9a2a8a2..5cace73ec0b 100644 --- a/src/builder/create_command.rs +++ b/src/builder/create_command.rs @@ -114,7 +114,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), @@ -126,7 +126,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 { @@ -248,13 +248,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 }