Small fixes
continuous-integration/woodpecker the build was successful Details

+ Improved location format
+ Added an error message for invalid link codes
+ Clippy + fmt
main
Joey Hines 2021-12-20 20:34:56 -07:00
parent 6bc80af865
commit 99a78599c7
No known key found for this signature in database
GPG Key ID: 80F567B5C968F91B
3 changed files with 14 additions and 2 deletions

View File

@ -9,6 +9,8 @@ use crate::bot::commands::{BotCommand, CommandError};
use geoffrey_models::models::parameters::register_params::RegisterParameters; use geoffrey_models::models::parameters::register_params::RegisterParameters;
use geoffrey_models::models::player::{Player, UserID}; use geoffrey_models::models::player::{Player, UserID};
use serenity::builder::CreateApplicationCommand; use serenity::builder::CreateApplicationCommand;
use geoffrey_models::models::response::api_error::GeoffreyAPIError;
use crate::bot::lang::ACCOUNT_LINK_INVALID;
pub struct RegisterCommand; pub struct RegisterCommand;
@ -25,6 +27,15 @@ impl BotCommand for RegisterCommand {
Method::POST Method::POST
} }
fn custom_err_resp(err: &CommandError) -> Option<String> {
match err {
CommandError::GeoffreyApi(GeoffreyAPIError::AccountLinkInvalid) => {
Some(ACCOUNT_LINK_INVALID.to_string())
}
_ => None
}
}
fn create_app_command(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand { fn create_app_command(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
command command
.name(Self::command_name()) .name(Self::command_name())

View File

@ -4,3 +4,4 @@ pub const PLAYER_DOES_NOT_HAVE_MATCHING_SHOP: &str =
"You don't have a shop by that name, try again champ."; "You don't have a shop by that name, try again champ.";
pub const PLAYER_ALREADY_SELLS_ITEM: &str = "You already sell that ding dong"; pub const PLAYER_ALREADY_SELLS_ITEM: &str = "You already sell that ding dong";
pub const NO_LOCATION_FOUND: &str = "No location found by that name goober"; pub const NO_LOCATION_FOUND: &str = "No location found by that name goober";
pub const ACCOUNT_LINK_INVALID: &str = "Your link code is invalid. You may need a new one. Or to git gud.";

View File

@ -89,8 +89,8 @@ impl Display for Position {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!( write!(
f, f,
"(x={}, y={}, z={}) {} ", "({} x={}, y={}, z={}) ",
self.x, self.y, self.z, self.dimension self.dimension ,self.x, self.y, self.z
) )
} }
} }