|
|
|
@ -3,11 +3,14 @@ mod commands;
|
|
|
|
mod data_loader;
|
|
|
|
mod data_loader;
|
|
|
|
mod utils;
|
|
|
|
mod utils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use std::collections::HashSet;
|
|
|
|
|
|
|
|
|
|
|
|
use serenity::async_trait;
|
|
|
|
use serenity::async_trait;
|
|
|
|
|
|
|
|
use serenity::prelude::*;
|
|
|
|
|
|
|
|
use serenity::model::prelude::*;
|
|
|
|
use serenity::model::channel::Message;
|
|
|
|
use serenity::model::channel::Message;
|
|
|
|
use serenity::model::gateway::Ready;
|
|
|
|
use serenity::model::gateway::Ready;
|
|
|
|
use serenity::prelude::*;
|
|
|
|
use serenity::http::Http;
|
|
|
|
// use serenity::model::prelude::*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Handler;
|
|
|
|
struct Handler;
|
|
|
|
|
|
|
|
|
|
|
|
@ -46,6 +49,16 @@ async fn main()
|
|
|
|
Err(why) => panic!("Could not load app token: {}", why),
|
|
|
|
Err(why) => panic!("Could not load app token: {}", why),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fetch the application owner id
|
|
|
|
|
|
|
|
let http = Http::new(&token);
|
|
|
|
|
|
|
|
let owner = match http.get_current_application_info().await
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Ok(info) => info.owner.id,
|
|
|
|
|
|
|
|
Err(why) => panic!("Could not access application info: {:?}", why),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
println!("Connecting...");
|
|
|
|
println!("Connecting...");
|
|
|
|
|
|
|
|
|
|
|
|
let intents = GatewayIntents::GUILD_MESSAGES
|
|
|
|
let intents = GatewayIntents::GUILD_MESSAGES
|
|
|
|
@ -57,6 +70,10 @@ async fn main()
|
|
|
|
// by Discord for bot users.
|
|
|
|
// by Discord for bot users.
|
|
|
|
let mut client = Client::builder(&token, intents).event_handler(Handler).await.expect("Err creating client");
|
|
|
|
let mut client = Client::builder(&token, intents).event_handler(Handler).await.expect("Err creating client");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: See link for how to add global data to the client:
|
|
|
|
|
|
|
|
// https://github.com/serenity-rs/serenity/blob/current/examples/e12_global_data/src/main.rs
|
|
|
|
|
|
|
|
// client.data.write().await.insert::<UserId>(owner);
|
|
|
|
|
|
|
|
|
|
|
|
// Finally, start a single shard, and start listening to events.
|
|
|
|
// Finally, start a single shard, and start listening to events.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Shards will automatically attempt to reconnect, and will perform
|
|
|
|
// Shards will automatically attempt to reconnect, and will perform
|
|
|
|
|