diff --git a/src/api.rs b/src/commands/api.rs similarity index 75% rename from src/api.rs rename to src/commands/api.rs index cc27990..8d7b885 100644 --- a/src/api.rs +++ b/src/commands/api.rs @@ -9,15 +9,19 @@ fn generate_signature(timestamp: String) -> String { let dev_id = std::env::var("DEV_ID") .expect("Missing DEV_ID"); let auth_key = std::env::var("AUTH_KEY") - .expect("Missing AUTH_KEY"); + .expect("Missing AUTH_KEY"); // Get Hi-Rez API credentials from env let signature = md5::compute(format!("{}createsession{}{}", dev_id, auth_key, timestamp)); return format!("{:?}", signature); } -pub(crate) async fn create_session() -> Result<(), Error> { +fn create_session() -> Result<(), Error> { let timestamp = get_utc_timestamp(); let signature: String = generate_signature(timestamp); println!("{}", signature); Ok(()) } + +pub(crate) fn get_random_god() -> &'static str { + return "some god"; +} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index a32f99d..1b6867c 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -2,3 +2,4 @@ pub(crate) mod slur; pub(crate) mod team; pub(crate) mod random; +mod api; diff --git a/src/commands/random.rs b/src/commands/random.rs index 353b0f9..aa00c2b 100644 --- a/src/commands/random.rs +++ b/src/commands/random.rs @@ -1,5 +1,7 @@ use crate::{Context, Error}; +use crate::commands::api::get_random_god; + /// Picks a random something #[poise::command(slash_command, subcommands("god", "mode"))] pub(crate) async fn random( @@ -13,7 +15,9 @@ pub(crate) async fn random( pub(crate) async fn god( ctx: Context<'_>, ) -> Result<(), Error> { - ctx.say("Waiting for that sweet API access.").await?; + let god = get_random_god(); + + ctx.say(format!("{}", god)).await?; Ok(()) } diff --git a/src/commands/slur.rs b/src/commands/slur.rs index 6b5a921..a0309fc 100644 --- a/src/commands/slur.rs +++ b/src/commands/slur.rs @@ -1,5 +1,5 @@ use crate::{Context, Error}; - +use crate::serenity; use rand::seq::IteratorRandom; use std::{ fs::File, @@ -19,6 +19,11 @@ pub(crate) async fn slur( let quote = quotes.choose(&mut rand::thread_rng()) .expect("No lines in file."); // Pick a random quote - ctx.say(quote).await?; + ctx.send(|f| f + .embed(|f| f + .title("DMBrandon Sez:") + .description(format!("\"{}\"", quote)) + .color(serenity::Colour::BLUE) + )).await?; // Send embed with team picks Ok(()) } diff --git a/src/commands/team.rs b/src/commands/team.rs index d61f1a0..1801deb 100644 --- a/src/commands/team.rs +++ b/src/commands/team.rs @@ -13,14 +13,23 @@ pub(crate) async fn team( let mut v = ctx.guild().unwrap().voice_states; // Get hashmap of users' voice states within the guild v.retain(|_, s| s.channel_id == Some(channel.id())); // Drop users not active in requested voice channel from hashmap - ctx.send(|f| f - .embed(|f| f - .title(format!("Custom {}v{} Teams", size, size)) - .description("I'm not done with this yet.") - .field("Order", "Some names", true) - .field("Chaos", "Other names", true) - .field("Spectators", "You guessed it, names.", false) - .color(serenity::Colour::DARK_GREEN) - )).await?; + if v.keys().len() < size as usize { // Make sure there are enough members in the voice channel + ctx.send(|f| f + .embed(|f| f + .title(format!("Custom {}v{} Teams", size, size)) + .description("You don't have enough friends for that, idiot.") + .color(serenity::Colour::RED) + )).await?; // Insult the user for not having enough members in call + } else { + ctx.send(|f| f + .embed(|f| f + .title(format!("Custom {}v{} Teams", size, size)) + .description("I'm not done with this yet.") + .field("Order", "Some names", true) + .field("Chaos", "Other names", true) + .field("Spectators", "You guessed it, names.", false) + .color(serenity::Colour::DARK_GREEN) + )).await?; // Send embed with team picks + } Ok(()) } diff --git a/src/main.rs b/src/main.rs index 3c0a841..5e784af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ mod commands; -mod api; use poise::serenity_prelude as serenity;