main.rs 1.49 KB
Newer Older
tec's avatar
tec committed
1
2
3
#[macro_use]
extern crate lazy_static;

tec's avatar
tec committed
4
5
#[macro_use]
extern crate log;
6
extern crate indexmap;
tec's avatar
tec committed
7
8
9
extern crate simplelog;
#[macro_use]
extern crate guard;
tec's avatar
tec committed
10
11
12
13
14

#[macro_use]
extern crate diesel;
extern crate ldap3;

15
16
extern crate reqwest;

17
18
extern crate tokio;

tec's avatar
tec committed
19
use simplelog::*;
20
use std::fs::File;
tec's avatar
tec committed
21

22
use serenity::client::Client;
tec's avatar
tec committed
23

24
25
#[macro_use]
mod util;
tec's avatar
tec committed
26
mod config;
tec's avatar
tec committed
27
28
mod database;
mod ldap;
tec's avatar
tec committed
29
mod reaction_roles;
30
mod serenity_handler;
tec's avatar
tec committed
31
mod token_management;
tec's avatar
tec committed
32
mod user_management;
tec's avatar
tec committed
33
mod voting;
tec's avatar
tec committed
34

35
36
use config::SECRETS;
use serenity_handler::Handler;
tec's avatar
tec committed
37

38
39
#[tokio::main]
async fn main() {
tec's avatar
tec committed
40
    CombinedLogger::init(vec![
41
        TermLogger::new(LevelFilter::Info, Config::default(), TerminalMode::Mixed),
tec's avatar
tec committed
42
43
44
45
46
47
48
        WriteLogger::new(
            LevelFilter::Info,
            Config::default(),
            File::create("ucc-bot.log").unwrap(),
        ),
    ])
    .unwrap();
49

50
51
    // ical::fetch_latest_ical().wait();

tec's avatar
tec committed
52
53
54
    // 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
    // by Discord for bot users.
55
56
57
58
    let mut client = Client::builder(&SECRETS.discord_token)
        .event_handler(Handler)
        .await
        .expect("Err creating client");
tec's avatar
tec committed
59
60
61
62
63

    // Finally, start a single shard, and start listening to events.
    //
    // Shards will automatically attempt to reconnect, and will perform
    // exponential backoff until it reconnects.
64
    if let Err(why) = client.start().await {
tec's avatar
tec committed
65
        error!("Client error: {:?}", why);
tec's avatar
tec committed
66
67
    }
}