diff options
Diffstat (limited to 'src/util/mod.rs')
| -rw-r--r-- | src/util/mod.rs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/util/mod.rs b/src/util/mod.rs index 38f4e55..474d36d 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -1,19 +1,9 @@ use std::{ - cmp::max_by, collections::HashMap, - process::{ - id, - Stdio, - }, + process::Stdio, }; -use anyhow::anyhow; use chrono::Duration; -use diesel::row::NamedRow; -use fnv::{ - FnvHashMap, - FnvHashSet, -}; use grate::tracing; use lazy_static::lazy_static; use poise::{ @@ -26,7 +16,6 @@ use regex::{ }; use serenity::{ all::{ - ChannelType, CreateMessage, GuildId, GuildRef, @@ -83,9 +72,9 @@ pub async fn users_listening(ctx: PoiseContext<'_>) -> anyhow::Result<bool> { pub fn msg<U, E>(ctx: poise::Context<'_, U, E>) -> Option<&Message> { match ctx { poise::Context::Prefix(poise::PrefixContext { - msg, - .. - }) => Some(msg), + msg, + .. + }) => Some(msg), _ => None, } } @@ -126,6 +115,18 @@ pub fn unwrap_tts<U, E>(ctx: poise::Context<'_, U, E>) -> bool { } #[inline] +pub async fn volume(ctx: PoiseContext<'_>) -> f64 { + let Some(guild_id) = ctx.guild_id() else { + return 1.; + }; + + let data = ctx.serenity_context().data.read().await; + let vol = data.get::<crate::bot::VolumeKey>().unwrap(); + + vol.get(&guild_id).map(|g| *g).unwrap_or(1.) +} + +#[inline] pub async fn send( ctx: &Context, channel: ChannelId, |
