started adding commands
This commit is contained in:
parent
6de542264a
commit
27c62e6ac2
54
src/commands/info_cmds.rs
Normal file
54
src/commands/info_cmds.rs
Normal file
@ -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(())
|
||||||
|
}
|
3
src/commands/mod.rs
Normal file
3
src/commands/mod.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub mod info_cmds;
|
||||||
|
pub mod reminder_cmds;
|
||||||
|
pub mod todo_cmds;
|
0
src/commands/reminder_cmds.rs
Normal file
0
src/commands/reminder_cmds.rs
Normal file
0
src/commands/todo_cmds.rs
Normal file
0
src/commands/todo_cmds.rs
Normal file
@ -36,7 +36,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::SQLPool;
|
use crate::SQLPool;
|
||||||
use serenity::model::id::RoleId;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PermissionLevel {
|
pub enum PermissionLevel {
|
||||||
@ -162,8 +161,8 @@ impl RegexFramework {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_command(mut self, name: String, command: &'static Command) -> Self {
|
pub fn add_command(mut self, name: &str, command: &'static Command) -> Self {
|
||||||
self.commands.insert(name, command);
|
self.commands.insert(name.to_string(), command);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@ -269,7 +268,7 @@ impl Framework for RegexFramework {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Err(sqlx::Error::RowNotFound) => {
|
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)
|
.execute(&pool)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -1,4 +1,5 @@
|
|||||||
mod framework;
|
mod framework;
|
||||||
|
mod commands;
|
||||||
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
client::{
|
client::{
|
||||||
@ -34,6 +35,11 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::framework::RegexFramework;
|
use crate::framework::RegexFramework;
|
||||||
|
use crate::commands::{
|
||||||
|
info_cmds,
|
||||||
|
reminder_cmds,
|
||||||
|
todo_cmds,
|
||||||
|
};
|
||||||
|
|
||||||
struct SQLPool;
|
struct SQLPool;
|
||||||
|
|
||||||
@ -56,7 +62,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||||||
let framework = RegexFramework::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID from environment").parse()?)
|
let framework = RegexFramework::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID from environment").parse()?)
|
||||||
.ignore_bots(true)
|
.ignore_bots(true)
|
||||||
.default_prefix("$")
|
.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();
|
.build();
|
||||||
|
|
||||||
let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment"))
|
let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment"))
|
||||||
|
Loading…
Reference in New Issue
Block a user