Commit c7c4f395 authored by Timothy du Heaume's avatar Timothy du Heaume

load config from a file

parent 48a78062
......@@ -10,3 +10,5 @@ rand = "^0.7.2"
lazy_static = "^1.4.0"
log = "^0.4.8"
simplelog = "^0.7.4"
toml = "^0.5.6"
serde = "^1.0.104"
use serenity;
use std::fs;
use serde::Deserialize;
use toml;
pub const CONFIG: UccbotConfig = UccbotConfig {
discord_token: include_str!("discord_token"),
server_id: 606351521117896704,
main_channel: serenity::model::id::ChannelId(606351521117896706),
welcome_channel: serenity::model::id::ChannelId(606351613816209418),
announcement_channel: serenity::model::id::ChannelId(606351521117896706),
bot_id: 607078903969742848,
vote_pool_size: 2,
vote_role: 607478818038480937,
tiebreaker_role: 607509283483025409,
unregistered_member_role: 608282247350714408,
registered_member_role: 608282133118582815,
command_prefix: "!",
for_vote: "👍",
against_vote: "👎",
abstain_vote: "🙊",
approve_react: "⬆",
disapprove_react: "⬇",
unsure_react: "❔",
};
lazy_static! {
static ref CONFIG_FILE: String = fs::read_to_string("config.toml").unwrap();
}
lazy_static! {
pub static ref CONFIG: UccbotConfig = toml::from_str(&CONFIG_FILE).unwrap();
}
pub static DISCORD_TOKEN: &str = include_str!("discord_token");
#[derive(Deserialize)]
pub struct UccbotConfig {
pub discord_token: &'static str,
pub server_id: u64,
// #general
pub main_channel: serenity::model::id::ChannelId,
......
use serenity;
pub static DISCORD_TOKEN: &str = include_str!("discord_token");
pub static SERVER_ID: u64 = 606351521117896704;
// #general
pub static MAIN_CHANNEL: serenity::model::id::ChannelId =
serenity::model::id::ChannelId(606351521117896706);
// #the-corner
pub static WELCOME_CHANNEL: serenity::model::id::ChannelId =
serenity::model::id::ChannelId(606351613816209418);
// #general
pub static ANNOUNCEMENT_CHANNEL: serenity::model::id::ChannelId =
serenity::model::id::ChannelId(606351521117896706);
pub static BOT_ID: u64 = 607078903969742848;
pub static VOTE_POOL_SIZE: i8 = 2;
pub static VOTE_ROLE: u64 = 607478818038480937;
pub static TIEBREAKER_ROLE: u64 = 607509283483025409;
pub static UNREGISTERED_MEMBER_ROLE: u64 = 608282247350714408;
pub static REGISTERED_MEMBER_ROLE: u64 = 608282133118582815;
pub static COMMAND_PREFIX: &str = "!";
pub static FOR_VOTE: &str = "👍";
pub static AGAINST_VOTE: &str = "👎";
pub static ABSTAIN_VOTE: &str = "🙊";
pub static APPROVE_REACT: &str = "⬆";
pub static DISAPPROVE_REACT: &str = "⬇";
pub static UNSURE_REACT: &str = "❔";
pub static ALLOWED_REACTS: &[&'static str] = &[
FOR_VOTE,
AGAINST_VOTE,
ABSTAIN_VOTE,
APPROVE_REACT,
DISAPPROVE_REACT,
UNSURE_REACT,
];
server_id = 606351521117896704
#general
main_channel = 606351521117896706
#the-corner
welcome_channel = 606351613816209418
#general
announcement_channel = 606351521117896706
bot_id = 607078903969742848
vote_pool_size = 2
vote_role = 607478818038480937
tiebreaker_role = 607509283483025409
unregistered_member_role = 608282247350714408
registered_member_role = 608282133118582815
command_prefix = "!"
for_vote = "👍"
against_vote = "👎"
abstain_vote = "🙊"
approve_react = "⬆"
disapprove_react = "⬇"
unsure_react = "❔"
server_id = 606351521117896704
#general
main_channel = 606351521117896706
#the-corner
welcome_channel = 606351613816209418
#general
announcement_channel = 606351521117896706
bot_id = 607078903969742848
vote_pool_size = 2
vote_role = 607478818038480937
tiebreaker_role = 607509283483025409
unregistered_member_role = 608282247350714408
registered_member_role = 608282133118582815
command_prefix = "!"
for_vote = "👍"
against_vote = "👎"
abstain_vote = "🙊"
approve_react = "⬆"
disapprove_react = "⬇"
unsure_react = "❔"
use serenity;
pub static DISCORD_TOKEN: &str = include_str!("discord_token");
pub static SERVER_ID: u64 = 264401248676085760;
// #ucc
pub static MAIN_CHANNEL: serenity::model::id::ChannelId =
serenity::model::id::ChannelId(264401248676085760);
// #welcome
pub static WELCOME_CHANNEL: serenity::model::id::ChannelId =
serenity::model::id::ChannelId(606750983699300372);
// #committee
pub static ANNOUNCEMENT_CHANNEL: serenity::model::id::ChannelId =
serenity::model::id::ChannelId(264411219627212801);
pub static BOT_ID: u64 = 635407267881156618;
pub static VOTE_POOL_SIZE: i8 = 7;
pub static VOTE_ROLE: u64 = 269817189966544896;
pub static TIEBREAKER_ROLE: u64 = 635370432568098817;
pub static UNREGISTERED_MEMBER_ROLE: u64 = 0; // does not exist
pub static REGISTERED_MEMBER_ROLE: u64 = 0; // does not exist
pub static COMMAND_PREFIX: &str = "!";
pub static FOR_VOTE: &str = "👍";
pub static AGAINST_VOTE: &str = "👎";
pub static ABSTAIN_VOTE: &str = "🙊";
pub static APPROVE_REACT: &str = "⬆";
pub static DISAPPROVE_REACT: &str = "⬇";
pub static UNSURE_REACT: &str = "❔";
pub static ALLOWED_REACTS: &[&'static str] = &[
FOR_VOTE,
AGAINST_VOTE,
ABSTAIN_VOTE,
APPROVE_REACT,
DISAPPROVE_REACT,
UNSURE_REACT,
];
server_id = 264401248676085760
#ucc
main_channel = 264401248676085760
#welcome
welcome_channel = 606750983699300372
#committee
announcement_channel = 264411219627212801
bot_id = 635407267881156618
vote_pool_size = 7
vote_role = 269817189966544896
tiebreaker_role = 635370432568098817
unregistered_member_role = 0 # does not exist
registered_member_role = 0 # does not exist
command_prefix = "!"
for_vote = "👍"
against_vote = "👎"
abstain_vote = "🙊"
approve_react = "⬆"
disapprove_react = "⬇"
unsure_react = "❔"
......@@ -155,7 +155,7 @@ fn main() {
// Configure the client with your Discord bot token in the environment.
let token = CONFIG.discord_token;
let token = config::DISCORD_TOKEN;
// Create a new instance of the Client, logging in as a bot. This will
// automatically prepend your bot token with "Bot ", which is a requirement
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment