mirror of
https://github.com/mii443/fendbot.git
synced 2025-08-22 15:05:38 +00:00
move context command to fend subcommand
This commit is contained in:
@ -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(())
|
||||
}
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user