summaryrefslogtreecommitdiff
path: root/src/commands/general
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/general')
-rw-r--r--src/commands/general/ask.rs17
-rw-r--r--src/commands/general/bing.rs9
-rw-r--r--src/commands/general/convert.rs55
-rw-r--r--src/commands/general/mod.rs11
-rw-r--r--src/commands/general/random.rs29
-rw-r--r--src/commands/general/version.rs38
6 files changed, 159 insertions, 0 deletions
diff --git a/src/commands/general/ask.rs b/src/commands/general/ask.rs
new file mode 100644
index 0000000..4bbf82e
--- /dev/null
+++ b/src/commands/general/ask.rs
@@ -0,0 +1,17 @@
+use crate::{consts, utils, Context};
+use color_eyre::eyre::{Context as _, Result};
+
+/// ask teawie a question!
+#[poise::command(prefix_command, slash_command)]
+pub async fn ask(
+ ctx: Context<'_>,
+ #[description = "the question you want to ask teawie"]
+ #[rename = "question"]
+ _question: String,
+) -> Result<()> {
+ let resp = utils::random_choice(consts::RESPONSES)
+ .wrap_err("Couldn't choose from random responses!")?;
+
+ ctx.say(resp).await?;
+ Ok(())
+}
diff --git a/src/commands/general/bing.rs b/src/commands/general/bing.rs
new file mode 100644
index 0000000..fefbaf1
--- /dev/null
+++ b/src/commands/general/bing.rs
@@ -0,0 +1,9 @@
+use crate::Context;
+use color_eyre::eyre::Result;
+
+/// make sure the wie is alive
+#[poise::command(prefix_command)]
+pub async fn bing(ctx: Context<'_>) -> Result<()> {
+ ctx.say("bong!").await?;
+ Ok(())
+}
diff --git a/src/commands/general/convert.rs b/src/commands/general/convert.rs
new file mode 100644
index 0000000..60135c4
--- /dev/null
+++ b/src/commands/general/convert.rs
@@ -0,0 +1,55 @@
+use crate::Context;
+use bottomify::bottom;
+use color_eyre::eyre::Result;
+
+#[poise::command(
+ slash_command,
+ subcommands("to_fahrenheit", "to_celsius", "to_bottom", "from_bottom")
+)]
+pub async fn convert(_ctx: Context<'_>) -> Result<()> {
+ 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<()> {
+ 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<()> {
+ let temp = (degrees_celsius * (9.0 / 5.0)) + 32.0;
+ ctx.say(temp.to_string()).await?;
+ Ok(())
+}
+
+/// teawie will translate to bottom 🥺
+#[poise::command(slash_command)]
+pub async fn to_bottom(
+ ctx: Context<'_>,
+ #[description = "what teawie will translate into bottom"] message: String,
+) -> Result<()> {
+ let encoded = bottom::encode_string(&message);
+ ctx.say(encoded).await?;
+ Ok(())
+}
+
+/// teawie will translate from bottom 🥸
+#[poise::command(slash_command)]
+pub async fn from_bottom(
+ ctx: Context<'_>,
+ #[description = "what teawie will translate from bottom"] message: String,
+) -> Result<()> {
+ let decoded = bottom::decode_string(&message)?;
+ ctx.say(decoded).await?;
+ Ok(())
+}
diff --git a/src/commands/general/mod.rs b/src/commands/general/mod.rs
new file mode 100644
index 0000000..ffb4d63
--- /dev/null
+++ b/src/commands/general/mod.rs
@@ -0,0 +1,11 @@
+mod ask;
+mod bing;
+mod convert;
+mod random;
+mod version;
+
+pub use ask::ask;
+pub use bing::bing;
+pub use convert::convert;
+pub use random::random;
+pub use version::version;
diff --git a/src/commands/general/random.rs b/src/commands/general/random.rs
new file mode 100644
index 0000000..9aa282a
--- /dev/null
+++ b/src/commands/general/random.rs
@@ -0,0 +1,29 @@
+use crate::{api, consts, utils, Context};
+use color_eyre::eyre::Result;
+
+#[poise::command(slash_command, subcommands("lore", "teawie", "shiggy"))]
+pub async fn random(_ctx: Context<'_>) -> Result<()> {
+ Ok(())
+}
+
+/// get a random piece of teawie lore!
+#[poise::command(prefix_command, slash_command)]
+pub async fn lore(ctx: Context<'_>) -> Result<()> {
+ let resp = utils::random_choice(consts::LORE)?;
+ ctx.say(resp).await?;
+ Ok(())
+}
+
+/// get a random teawie
+#[poise::command(prefix_command, slash_command)]
+pub async fn teawie(ctx: Context<'_>) -> Result<()> {
+ let url = api::guzzle::get_random_teawie().await?;
+ utils::send_url_as_embed(ctx, url).await
+}
+
+/// get a random shiggy
+#[poise::command(prefix_command, slash_command)]
+pub async fn shiggy(ctx: Context<'_>) -> Result<()> {
+ let url = api::shiggy::get_random_shiggy().await?;
+ utils::send_url_as_embed(ctx, url).await
+}
diff --git a/src/commands/general/version.rs b/src/commands/general/version.rs
new file mode 100644
index 0000000..8b8d1f1
--- /dev/null
+++ b/src/commands/general/version.rs
@@ -0,0 +1,38 @@
+use crate::colors::Colors;
+use crate::Context;
+use color_eyre::eyre::Result;
+
+/// get version info
+#[poise::command(slash_command)]
+pub async fn version(ctx: Context<'_>) -> Result<()> {
+ let sha = option_env!("GIT_SHA").unwrap_or("main");
+
+ let revision_url = format!(
+ "[{}]({}/tree/{})",
+ sha,
+ option_env!("CARGO_PKG_REPOSITORY").unwrap_or("https://github.com/getchoo/teawieBot"),
+ sha,
+ );
+
+ let fields = [
+ (
+ "Version:",
+ option_env!("CARGO_PKG_VERSION").unwrap_or("not found"),
+ false,
+ ),
+ ("Revision:", &revision_url, false),
+ ("User Agent:", &crate::api::USER_AGENT, false),
+ ];
+
+ ctx.send(|c| {
+ c.embed(|e| {
+ e.title("Version Information")
+ .description("powered by poise!")
+ .fields(fields)
+ .color(Colors::Blue)
+ })
+ })
+ .await?;
+
+ Ok(())
+}