use crate::error::{ManifoldError, ManifoldResult}; use crate::{ManifoldContext, ManifoldData}; #[poise::command(slash_command, prefix_command, aliases("c"), subcommands("ftoc", "ftok", "ftor", "ctof", "ctok", "ctor", "rtof", "rtoc", "rtok", "ktoc", "ktof", "ktor"))] pub async fn convert(ctx: ManifoldContext<'_>) -> ManifoldResult<()> { ctx.send(|f| f.content("Specify a conversion. See help for more info").reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ftoc(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°F is {}°C", value, ((value - 32.0)/1.8))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ftok(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°F is {}°K", value, (((value - 32.0)/1.8) + 273.0))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ftor(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°F is {}°R", value, (value + 459.67))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ctof(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°C is {}°F", value, ((value * 1.8)+32.0))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ctok(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°C is {}°K", value, (value + 273.15))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ctor(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°C is {}°R", value, ((value + 273.15) * (9.0/5.0)))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ktoc(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°K is {}°C", value, (value - 273.15))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ktof(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°K is {}°F", value, ((value * (9.0/5.0)) - 459.67))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn ktor(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°K is {}°R", value, (value * (9.0/5.0)))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn rtok(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°R is {}°K", value, (value * (5.0/9.0)))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn rtoc(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°R is {}°C", value, ((value - 491.67) * (5.0/9.0)))).reply(true)).await?; Ok(()) } #[poise::command(slash_command, prefix_command)] pub async fn rtof(ctx: ManifoldContext<'_>, value: f32) -> ManifoldResult<()> { ctx.send(|f| f.content(format!("{}°R is {}°F", value, (value - 459.67))).reply(true)).await?; Ok(()) } pub fn commands() -> [poise::Command; 13] { [convert(), ftoc(), ftok(), ftor(), ctof(), ctok(), ctor(), ktoc(), ktof(), ktor(), rtok(), rtoc(), rtof()] }