summaryrefslogtreecommitdiff
path: root/src/settings.rs
diff options
context:
space:
mode:
authorseth <[email protected]>2023-11-30 22:44:26 -0500
committerseth <[email protected]>2023-12-01 07:12:49 -0500
commit41dfa94258215769b9d844875e79097d4a498770 (patch)
tree5fb5a42545477ea1958ca6e5a1c1ae9b8d4899f7 /src/settings.rs
parent76c0f94e6d7aa108424b34826eb7d8514b026287 (diff)
refactor: expand Settings
Diffstat (limited to 'src/settings.rs')
-rw-r--r--src/settings.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/settings.rs b/src/settings.rs
index f0fef31..5cf0dec 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -1,9 +1,10 @@
-use crate::utils;
+use crate::{consts, utils};
use log::*;
-use poise::serenity_prelude::{ChannelId, EmojiId, MessageReaction, ReactionType};
+use poise::serenity_prelude::{ChannelId, EmojiId, GuildId, MessageReaction, ReactionType};
#[derive(Clone)]
pub struct Settings {
+ pub allowed_guilds: Vec<GuildId>,
pub pinboard_target: ChannelId,
pub pinboard_sources: Option<Vec<ChannelId>>,
pub reactboard_target: ChannelId,
@@ -14,6 +15,9 @@ pub struct Settings {
impl Settings {
pub fn new() -> Option<Self> {
+ let allowed_guilds = utils::parse_snowflakes_from_env("ALLOWED_GUILDS", GuildId)
+ .unwrap_or_else(|| vec![consts::TEAWIE_GUILD, GuildId(1091969030694375444)]);
+
let Some(pinboard_target) = utils::parse_snowflake_from_env("PIN_BOARD_TARGET", ChannelId)
else {
return None;
@@ -56,6 +60,7 @@ impl Settings {
);
Some(Self {
+ allowed_guilds,
pinboard_target,
pinboard_sources,
reactboard_target,
@@ -77,4 +82,8 @@ impl Settings {
_ => false,
}
}
+
+ pub fn is_guild_allowed(&self, gid: GuildId) -> bool {
+ self.allowed_guilds.contains(&gid)
+ }
}