blob: c7e09c99ce1627c071f55902db6ee69005963383 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
use crate::{Context, Error};
#[poise::command(slash_command, subcommands("to_fahrenheit", "to_celsius"))]
pub async fn convert(_ctx: Context<'_>) -> Result<(), Error> {
Ok(())
}
/// ask teawie to convert °F to °C
#[poise::command(slash_command)]
pub async fn to_celsius(
ctx: Context<'_>,
#[description = "what teawie will convert"] degrees_fahrenheit: f32,
) -> Result<(), Error> {
let temp = (degrees_fahrenheit - 32.0) * (5.0 / 9.0);
ctx.say(temp.to_string()).await?;
Ok(())
}
/// ask teawie to convert °C to °F
#[poise::command(slash_command)]
pub async fn to_fahrenheit(
ctx: Context<'_>,
#[description = "what teawie will convert"] degrees_celsius: f32,
) -> Result<(), Error> {
let temp = (degrees_celsius * (9.0 / 5.0)) + 32.0;
ctx.say(temp.to_string()).await?;
Ok(())
}
|