diff --git a/src/commands/info_cmds.rs b/src/commands/info_cmds.rs new file mode 100644 index 0000000..42ac6f3 --- /dev/null +++ b/src/commands/info_cmds.rs @@ -0,0 +1,54 @@ +use regex_command_attr::command; + +use serenity::{ + client::Context, + model::{ + channel::{ + Message, + }, + }, + framework::standard::{ + Args, CommandResult, + }, +}; +use crate::THEME_COLOR; + + +#[command] +async fn help(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { + msg.channel_id.send_message(ctx, |m| m + .embed(|e| e + .title("Help") + .description("Help Description") + .color(THEME_COLOR) + ) + ).await?; + + Ok(()) +} + +#[command] +async fn info(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { + msg.channel_id.send_message(ctx, |m| m + .embed(|e| e + .title("Info") + .description("Info Description") + .color(THEME_COLOR) + ) + ).await?; + + Ok(()) +} + +#[command] +async fn donate(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { + msg.channel_id.send_message(ctx, |m| m + .embed(|e| e + .title("Donate") + .description("Donate Description") + .color(THEME_COLOR) + ) + ).await?; + + Ok(()) +} diff --git a/src/commands/mod.rs b/src/commands/mod.rs new file mode 100644 index 0000000..9363010 --- /dev/null +++ b/src/commands/mod.rs @@ -0,0 +1,3 @@ +pub mod info_cmds; +pub mod reminder_cmds; +pub mod todo_cmds; diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/commands/todo_cmds.rs b/src/commands/todo_cmds.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/framework.rs b/src/framework.rs index 46a030f..60316b8 100644 --- a/src/framework.rs +++ b/src/framework.rs @@ -36,7 +36,6 @@ use std::{ }; use crate::SQLPool; -use serenity::model::id::RoleId; #[derive(Debug)] pub enum PermissionLevel { @@ -162,8 +161,8 @@ impl RegexFramework { self } - pub fn add_command(mut self, name: String, command: &'static Command) -> Self { - self.commands.insert(name, command); + pub fn add_command(mut self, name: &str, command: &'static Command) -> Self { + self.commands.insert(name.to_string(), command); self } @@ -269,7 +268,7 @@ impl Framework for RegexFramework { } Err(sqlx::Error::RowNotFound) => { - sqlx::query!("INSERT INTO guilds (guild, name) VALUES (?, ?)", guild.id.as_u64(), guild.name) + let _ = sqlx::query!("INSERT INTO guilds (guild, name) VALUES (?, ?)", guild.id.as_u64(), guild.name) .execute(&pool) .await; diff --git a/src/main.rs b/src/main.rs index a56ca3d..4aaa88a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ mod framework; +mod commands; use serenity::{ client::{ @@ -34,6 +35,11 @@ use std::{ }; use crate::framework::RegexFramework; +use crate::commands::{ + info_cmds, + reminder_cmds, + todo_cmds, +}; struct SQLPool; @@ -56,7 +62,9 @@ async fn main() -> Result<(), Box> { let framework = RegexFramework::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID from environment").parse()?) .ignore_bots(true) .default_prefix("$") - .add_command("look".to_string(), &LOOK_COMMAND) + .add_command("help", &info_cmds::HELP_COMMAND) + .add_command("info", &info_cmds::INFO_COMMAND) + .add_command("donate", &info_cmds::DONATE_COMMAND) .build(); let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment"))