use crate::utils::context_data::DatabaseContainer; use crate::utils::error::{BotError, BotResult}; use serenity::client::Context; use serenity::model::prelude::GuildId; use std::str::FromStr; pub static ALL_SETTINGS: &[Setting] = &[Setting::MusicAutoShuffle, Setting::BotAutoDelete]; #[derive(Clone, Debug)] pub enum Setting { MusicAutoShuffle, BotAutoDelete, } impl ToString for Setting { fn to_string(&self) -> String { match self { Self::MusicAutoShuffle => "music.autoshuffle".to_string(), Self::BotAutoDelete => "bot.autodelete".to_string(), } } } /// Returns a specific guild setting pub async fn get_setting( ctx: &Context, guild_id: GuildId, setting: Setting, ) -> BotResult> { let data = ctx.data.read().await; let database = data.get::().unwrap(); database .get_guild_setting::(guild_id.0, &setting.to_string()) .map_err(BotError::from) }