This commit is contained in:
jude-lafitteIII 2020-04-14 00:22:31 +01:00
parent 95ce2c7015
commit 7b8198aac0
3 changed files with 68 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "soundfx-rs"
version = "0.1.0"
authors = ["jude-lafitteIII <judewrs@gmail.com>"]
edition = "2018"
[dependencies]
serenity = "0.8"
sqlx = "0.3"
dotenv = "0.15"

57
src/main.rs Normal file
View File

@ -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<MySqlConnection>;
}
#[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::<SQLPool>(pool);
}
client.start().expect("Failed to start client");
}
#[command]
fn play() {
}