diff --git a/src/commands.rs b/src/commands.rs index e2d0765..9ca4c41 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -14,6 +14,41 @@ pub async fn register(ctx: Context<'_>) -> Result<(), Error> { Ok(()) } +#[poise::command( + prefix_command, + slash_command, + subcommands("context"), + subcommand_required +)] +pub async fn fend(_: Context<'_>) -> Result<(), Error> { + Ok(()) +} + +#[poise::command( + prefix_command, + slash_command, + subcommands("reset"), + subcommand_required +)] +pub async fn context(_: Context<'_>) -> Result<(), Error> { + Ok(()) +} + +#[poise::command(prefix_command, slash_command)] +pub async fn reset(ctx: Context<'_>) -> Result<(), Error> { + let id = ctx.author().id.get(); + + let mut data = ctx.data().context.lock().await; + + let context = create_context(); + save_context(&context, id); + + data.insert(id, context); + + ctx.reply("success").await.unwrap(); + Ok(()) +} + #[poise::command(prefix_command, slash_command)] pub async fn calc(ctx: Context<'_>, expr: String) -> Result<(), Error> { ctx.defer().await.unwrap(); @@ -66,18 +101,3 @@ pub async fn calc(ctx: Context<'_>, expr: String) -> Result<(), Error> { Ok(()) } - -#[poise::command(prefix_command, slash_command)] -pub async fn reset_context(ctx: Context<'_>) -> Result<(), Error> { - let id = ctx.author().id.get(); - - let mut data = ctx.data().context.lock().await; - - let context = create_context(); - save_context(&context, id); - - data.insert(id, context); - - ctx.reply("success").await.unwrap(); - Ok(()) -} diff --git a/src/main.rs b/src/main.rs index 73b4cfc..4741cba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ mod commands; mod context; use anyhow::Result; -use commands::{calc, register, reset_context}; +use commands::{calc, fend, register}; use context::restore_contexts; use std::{ collections::{HashMap, HashSet}, @@ -44,7 +44,7 @@ async fn main() -> Result<()> { }) }) .options(poise::FrameworkOptions { - commands: vec![register(), calc(), reset_context()], + commands: vec![register(), calc(), fend()], prefix_options: PrefixFrameworkOptions { prefix: Some(prefix), ..Default::default()