1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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 Properties {
GuildId,
PinBoardChannel,
PinBoardWatch,
PinBoardEnabled,
ReactBoardChannel,
ReactBoardRequirement,
ReactBoardReactions,
ReactBoardEnabled,
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 pinboard_enabled: bool,
pub reactboard_channel: Option<ChannelId>,
pub reactboard_requirement: Option<u64>,
pub reactboard_reactions: Option<Vec<ReactionType>>,
pub reactboard_enabled: bool,
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
}
}
}
|