diff options
| author | seth <[email protected]> | 2023-12-05 05:17:49 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2023-12-15 16:41:13 -0500 |
| commit | 815cb0df3b3e3f9dd2078b00f85754da87b1d55e (patch) | |
| tree | 85099483f8ebb0586bc097b65f6c5a2b5997150e /src/storage/settings.rs | |
| parent | 0ca61ddff6ec7404f0aeabc1c8c785bbc8db7fd5 (diff) | |
refactor: centralize storage handlers
Diffstat (limited to 'src/storage/settings.rs')
| -rw-r--r-- | src/storage/settings.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/storage/settings.rs b/src/storage/settings.rs new file mode 100644 index 0000000..c8a663d --- /dev/null +++ b/src/storage/settings.rs @@ -0,0 +1,37 @@ +use poise::serenity_prelude::{ChannelId, GuildId, ReactionType}; +use redis_macros::{FromRedisValue, ToRedisArgs}; +use serde::{Deserialize, Serialize}; + +pub const SETTINGS_KEY: &str = "settings-v1"; + +#[derive(poise::ChoiceParameter)] +pub enum SettingsProperties { + GuildId, + PinBoardChannel, + PinBoardWatch, + ReactBoardChannel, + ReactBoardRequirement, + ReactBoardReactions, + OptionalCommandsEnabled, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, FromRedisValue, ToRedisArgs)] +pub struct Settings { + pub guild_id: GuildId, + pub pinboard_channel: Option<ChannelId>, + pub pinboard_watch: Option<Vec<ChannelId>>, + pub reactboard_channel: Option<ChannelId>, + pub reactboard_requirement: Option<u64>, + pub reactboard_reactions: Option<Vec<ReactionType>>, + pub optional_commands_enabled: bool, +} + +impl Settings { + pub fn can_use_reaction(&self, reaction: &ReactionType) -> bool { + if let Some(reactions) = &self.reactboard_reactions { + reactions.iter().any(|r| r == reaction) + } else { + false + } + } +} |
