2020-08-06 14:22:13 +00:00
|
|
|
mod framework;
|
|
|
|
|
|
|
|
use serenity::{
|
|
|
|
client::{
|
|
|
|
bridge::gateway::GatewayIntents,
|
|
|
|
Client, Context,
|
|
|
|
},
|
|
|
|
model::{
|
|
|
|
channel::{
|
|
|
|
Message,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
framework::standard::{
|
|
|
|
Args, CommandResult,
|
|
|
|
},
|
|
|
|
prelude::TypeMapKey,
|
|
|
|
};
|
|
|
|
|
2020-08-06 18:18:30 +00:00
|
|
|
use regex_command_attr::command;
|
|
|
|
|
2020-08-06 14:22:13 +00:00
|
|
|
use sqlx::{
|
|
|
|
Pool,
|
|
|
|
mysql::{
|
|
|
|
MySqlConnection,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
use dotenv::dotenv;
|
|
|
|
|
|
|
|
use std::{
|
|
|
|
sync::Arc,
|
|
|
|
env,
|
|
|
|
};
|
|
|
|
|
2020-08-06 18:18:30 +00:00
|
|
|
use crate::framework::RegexFramework;
|
2020-08-06 14:22:13 +00:00
|
|
|
|
|
|
|
struct SQLPool;
|
|
|
|
|
|
|
|
impl TypeMapKey for SQLPool {
|
|
|
|
type Value = Pool<MySqlConnection>;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ReqwestClient;
|
|
|
|
|
|
|
|
impl TypeMapKey for ReqwestClient {
|
|
|
|
type Value = Arc<reqwest::Client>;
|
|
|
|
}
|
|
|
|
|
|
|
|
static THEME_COLOR: u32 = 0x00e0f3;
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|
|
|
dotenv()?;
|
|
|
|
|
2020-08-06 19:39:05 +00:00
|
|
|
println!("{:?}", HELP_COMMAND);
|
|
|
|
|
2020-08-07 00:02:01 +00:00
|
|
|
let framework = RegexFramework::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID from environment").parse()?)
|
2020-08-06 14:22:13 +00:00
|
|
|
.ignore_bots(true)
|
|
|
|
.default_prefix("$")
|
2020-08-06 18:18:30 +00:00
|
|
|
.add_command("help".to_string(), &HELP_COMMAND)
|
|
|
|
.add_command("h".to_string(), &HELP_COMMAND)
|
2020-08-06 14:22:13 +00:00
|
|
|
.build();
|
|
|
|
|
|
|
|
let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment"))
|
|
|
|
.intents(GatewayIntents::GUILD_MESSAGES | GatewayIntents::GUILDS | GatewayIntents::DIRECT_MESSAGES)
|
|
|
|
.framework(framework)
|
2020-08-06 18:18:30 +00:00
|
|
|
.await.expect("Error occurred creating client");
|
2020-08-06 14:22:13 +00:00
|
|
|
|
|
|
|
client.start_autosharded().await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[command]
|
2020-08-06 18:18:30 +00:00
|
|
|
async fn help(_ctx: &Context, _msg: &Message, _args: Args) -> CommandResult {
|
2020-08-06 14:22:13 +00:00
|
|
|
println!("Help command called");
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|