Update embed builders

This commit is contained in:
Em (Ethan) Ruszanowski 2023-01-12 14:18:11 -05:00
parent eb39ece900
commit ca376be31c
No known key found for this signature in database
GPG key ID: C3E7A3C0B1491DFE
6 changed files with 37 additions and 15 deletions

View file

@ -9,15 +9,19 @@ fn generate_signature(timestamp: String) -> String {
let dev_id = std::env::var("DEV_ID") let dev_id = std::env::var("DEV_ID")
.expect("Missing DEV_ID"); .expect("Missing DEV_ID");
let auth_key = std::env::var("AUTH_KEY") 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)); let signature = md5::compute(format!("{}createsession{}{}", dev_id, auth_key, timestamp));
return format!("{:?}", signature); return format!("{:?}", signature);
} }
pub(crate) async fn create_session() -> Result<(), Error> { fn create_session() -> Result<(), Error> {
let timestamp = get_utc_timestamp(); let timestamp = get_utc_timestamp();
let signature: String = generate_signature(timestamp); let signature: String = generate_signature(timestamp);
println!("{}", signature); println!("{}", signature);
Ok(()) Ok(())
} }
pub(crate) fn get_random_god() -> &'static str {
return "some god";
}

View file

@ -2,3 +2,4 @@
pub(crate) mod slur; pub(crate) mod slur;
pub(crate) mod team; pub(crate) mod team;
pub(crate) mod random; pub(crate) mod random;
mod api;

View file

@ -1,5 +1,7 @@
use crate::{Context, Error}; use crate::{Context, Error};
use crate::commands::api::get_random_god;
/// Picks a random something /// Picks a random something
#[poise::command(slash_command, subcommands("god", "mode"))] #[poise::command(slash_command, subcommands("god", "mode"))]
pub(crate) async fn random( pub(crate) async fn random(
@ -13,7 +15,9 @@ pub(crate) async fn random(
pub(crate) async fn god( pub(crate) async fn god(
ctx: Context<'_>, ctx: Context<'_>,
) -> Result<(), Error> { ) -> Result<(), Error> {
ctx.say("Waiting for that sweet API access.").await?; let god = get_random_god();
ctx.say(format!("{}", god)).await?;
Ok(()) Ok(())
} }

View file

@ -1,5 +1,5 @@
use crate::{Context, Error}; use crate::{Context, Error};
use crate::serenity;
use rand::seq::IteratorRandom; use rand::seq::IteratorRandom;
use std::{ use std::{
fs::File, fs::File,
@ -19,6 +19,11 @@ pub(crate) async fn slur(
let quote = quotes.choose(&mut rand::thread_rng()) let quote = quotes.choose(&mut rand::thread_rng())
.expect("No lines in file."); // Pick a random quote .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(()) Ok(())
} }

View file

@ -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 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 v.retain(|_, s| s.channel_id == Some(channel.id())); // Drop users not active in requested voice channel from hashmap
ctx.send(|f| f if v.keys().len() < size as usize { // Make sure there are enough members in the voice channel
.embed(|f| f ctx.send(|f| f
.title(format!("Custom {}v{} Teams", size, size)) .embed(|f| f
.description("I'm not done with this yet.") .title(format!("Custom {}v{} Teams", size, size))
.field("Order", "Some names", true) .description("You don't have enough friends for that, idiot.")
.field("Chaos", "Other names", true) .color(serenity::Colour::RED)
.field("Spectators", "You guessed it, names.", false) )).await?; // Insult the user for not having enough members in call
.color(serenity::Colour::DARK_GREEN) } else {
)).await?; 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(()) Ok(())
} }

View file

@ -1,5 +1,4 @@
mod commands; mod commands;
mod api;
use poise::serenity_prelude as serenity; use poise::serenity_prelude as serenity;