From 7b8198aac0fddd7116b53c49ee3dd2933f356abb Mon Sep 17 00:00:00 2001 From: jude-lafitteIII Date: Tue, 14 Apr 2020 00:22:31 +0100 Subject: [PATCH] initial --- .gitignore | 1 + Cargo.toml | 10 ++++++++++ src/main.rs | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..da0fbc3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "soundfx-rs" +version = "0.1.0" +authors = ["jude-lafitteIII "] +edition = "2018" + +[dependencies] +serenity = "0.8" +sqlx = "0.3" +dotenv = "0.15" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d741ec6 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,57 @@ +use serenity::{ + client::Client, + framework::StandardFramework, + prelude::{ + EventHandler, Context, TypeMapKey + } +}; + +use sqlx::{ + Pool, + mysql::MySqlPool +}; + +use dotenv::dotenv; + +use std::env; + +struct SQLPool; + +impl TypeMapKey for SQLPool { + type Value = Pool; +} + +#[group] +#[commands()] +struct Commands; + +// create event handler for bot +struct Handler; + +impl EventHandler for Handler {} + +// entry point +fn main() { + dotenv(); + + let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("Missing token from environment"), Handler).expect("Failed to create client"); + + client.with_framework(StandardFramework::new() + .configure(|c| c.prefix("?")) + .group(&GENERAL_GROUP)); + + { + let mut data = client.data.write(); + + let pool = MySqlPool::new(env::var("DATABASE_URL")); + + data.insert::(pool); + } + + client.start().expect("Failed to start client"); +} + +#[command] +fn play() { + +}