mirror of
https://github.com/ethanrusz/echbot.git
synced 2024-11-22 04:07:46 -05:00
Update embed builders
This commit is contained in:
parent
eb39ece900
commit
ca376be31c
6 changed files with 37 additions and 15 deletions
|
@ -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";
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
|
@ -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(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,14 @@ 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
|
||||||
|
|
||||||
|
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
|
ctx.send(|f| f
|
||||||
.embed(|f| f
|
.embed(|f| f
|
||||||
.title(format!("Custom {}v{} Teams", size, size))
|
.title(format!("Custom {}v{} Teams", size, size))
|
||||||
|
@ -21,6 +29,7 @@ pub(crate) async fn team(
|
||||||
.field("Chaos", "Other names", true)
|
.field("Chaos", "Other names", true)
|
||||||
.field("Spectators", "You guessed it, names.", false)
|
.field("Spectators", "You guessed it, names.", false)
|
||||||
.color(serenity::Colour::DARK_GREEN)
|
.color(serenity::Colour::DARK_GREEN)
|
||||||
)).await?;
|
)).await?; // Send embed with team picks
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
mod commands;
|
mod commands;
|
||||||
mod api;
|
|
||||||
|
|
||||||
use poise::serenity_prelude as serenity;
|
use poise::serenity_prelude as serenity;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue