From d4cae5b572880be77fee879a2d87d5b5a53a7d63 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 19 Jun 2022 17:55:59 +0200 Subject: [PATCH] no nougat :ferrisSob: --- Cargo.toml | 1 - src/handler.rs | 103 +------------------------------------------------ 2 files changed, 1 insertion(+), 103 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b4d9d59..6bfbadb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ tokio = { version = "1.19.2", features = ["full"] } tracing = "0.1.35" tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } serde = { version = "1.0.137", features = ["derive"] } -nougat = "0.1.0" serde_json = "1.0.81" poise = "0.2.2" diff --git a/src/handler.rs b/src/handler.rs index 0f7d7e9..c72c753 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -517,7 +517,7 @@ async fn prison_arrest_impl(ctx: crate::Context<'_>, user: User) -> color_eyre:: let role = match role { Some(role) => role, None => { - ctx.say("du mosch zerst e rolle setze mit /prison set_role"); + ctx.say("du mosch zerst e rolle setze mit /prison set_role").await?; return Ok(()); } }; @@ -584,104 +584,3 @@ async fn prison_release_impl(ctx: crate::Context<'_>, user: User) -> color_eyre: async fn error_handler(error: poise::FrameworkError<'_, Handler, Report>) { error!(?error, "Error during command execution"); } - -#[nougat::gat] -trait GetOption { - type Get<'a>; - - fn extract( - command: &ApplicationCommandInteractionDataOptionValue, - ) -> color_eyre::Result>; - - fn get( - option: Option<&ApplicationCommandInteractionDataOption>, - ) -> color_eyre::Result> { - let option = Self::get_optional(option); - match option { - Ok(Some(get)) => Ok(get), - Ok(None) => Err(eyre!("Expected value!")), - Err(err) => Err(err), - } - } - fn get_optional( - option: Option<&ApplicationCommandInteractionDataOption>, - ) -> color_eyre::Result>> { - if let Some(option) = option { - if let Some(command) = option.resolved.as_ref() { - Self::extract(command).map(Some) - } else { - Ok(None) - } - } else { - Ok(None) - } - } -} - -struct UserOption; - -#[nougat::gat] -impl GetOption for UserOption { - type Get<'a> = (&'a User, &'a Option); - - fn extract( - command: &ApplicationCommandInteractionDataOptionValue, - ) -> crate::Result> { - if let ApplicationCommandInteractionDataOptionValue::User(user, member) = command { - Ok((user, member)) - } else { - Err(eyre!("Expected user!")) - } - } -} - -struct StringOption; - -#[nougat::gat] -impl GetOption for StringOption { - type Get<'a> = &'a str; - - fn extract( - command: &ApplicationCommandInteractionDataOptionValue, - ) -> crate::Result> { - if let ApplicationCommandInteractionDataOptionValue::String(str) = command { - Ok(str) - } else { - Err(eyre!("Expected string!")) - } - } -} - -struct ChannelOption; - -#[nougat::gat] -impl GetOption for ChannelOption { - type Get<'a> = &'a PartialChannel; - - fn extract( - command: &ApplicationCommandInteractionDataOptionValue, - ) -> crate::Result> { - if let ApplicationCommandInteractionDataOptionValue::Channel(channel) = command { - Ok(channel) - } else { - Err(eyre!("Expected string!")) - } - } -} - -struct RoleOption; - -#[nougat::gat] -impl GetOption for RoleOption { - type Get<'a> = &'a Role; - - fn extract( - command: &ApplicationCommandInteractionDataOptionValue, - ) -> crate::Result> { - if let ApplicationCommandInteractionDataOptionValue::Role(role) = command { - Ok(role) - } else { - Err(eyre!("Expected string!")) - } - } -}