#![allow(non_snake_case)] extern crate serenity; extern crate parking_lot; extern crate rand; extern crate serde_json; extern crate typemap; mod confighandler; mod macros; mod player; use serenity::{ framework::standard::{ help_commands, macros::{check, command, group, help}, Args, CheckResult, CommandGroup, CommandOptions, CommandResult, DispatchError, HelpOptions, StandardFramework, }, model::{ channel::{Channel, Message}, gateway::Ready, id::UserId, }, utils::{content_safe, ContentSafeOptions}, }; // This imports `typemap`'s `Key` as `TypeMapKey`. use serenity::prelude::*; use std::sync::Arc; use confighandler::*; use player::prelude::*; struct Config { token: String, prefix: String, } impl Default for Config { fn default() -> Self { Self { token: String::new(), prefix: String::new(), } } } group!({ name: "general", options: {}, commands: [ip] }); fn main() { // read config file let config_file = check_result_return!(read_config("bot.conf")); let mut config = Config::default(); match config_file.get("Meta") { Some(info) => { match info.get("token") { Some(token_pair) => { display_error!(token_pair.set_value(&mut config.token)); } None => { println!("couldn't find token inside meta section"); return; } } match info.get("prefix") { Some(prefix_pair) => { display_error!(prefix_pair.set_value(&mut config.prefix)); } None => { println!("couldn't find prefix inside meta section"); return; } } } None => { println!("couldn't find Meta section in config file"); return; } }; let mut client = Client::new(&config.token, Handler).expect("Err creating client"); // Obtain a lock to the data owned by the client, and insert the client's // voice manager into it. This allows the voice manager to be accessible by // event handlers and framework commands. { let mut data = client.data.write(); data.insert::(Arc::clone(&client.voice_manager)); } let media_data = Arc::new(MediaData::new("Penis1").expect("failed to create media data handle")); /* client.with_framework( StandardFramework::new() .configure(|c| c.prefix(&config.prefix).on_mention(true)) .cmd("play", Play::new(media_data.clone())) .cmd("pause", Pause::new(media_data.clone())) .cmd( "help", Help::new( &config.prefix, vec![ "play".to_string(), "pause".to_string(), "stop".to_string(), "help".to_string(), "list".to_string(), "skip".to_string(), "remove".to_string(), "ip".to_string(), ], ), ) .cmd("stop", Stop::new(media_data.clone())) .cmd("list", List::new(media_data.clone())) .cmd("skip", Skip::new(media_data.clone())) .cmd("ip", IP::new()) .cmd("remove", Remove::new(media_data.clone())), ); let _ = client .start() .map_err(|why| println!("Client ended: {:?}", why)); */ }