- Added MapError::CannotReach variant - Updated Map::unlock_room_for_account to check reachableness - Added /info command - Added /unlock command - Added /move command - Added /reset command
54 lines
1.5 KiB
Rust
54 lines
1.5 KiB
Rust
use std::error::Error as StdError;
|
|
use poise::CreateReply;
|
|
|
|
use crate::{Context, Data, Error};
|
|
|
|
pub mod quest;
|
|
pub mod init;
|
|
pub mod answer;
|
|
pub mod social;
|
|
pub mod account;
|
|
pub mod map;
|
|
|
|
#[poise::command(prefix_command)]
|
|
pub async fn register(ctx: Context<'_>) -> Result<(), Error> {
|
|
poise::builtins::register_application_commands_buttons(ctx).await?;
|
|
Ok(())
|
|
}
|
|
|
|
#[poise::command(
|
|
prefix_command,
|
|
slash_command,
|
|
)]
|
|
pub async fn info(ctx: Context<'_>) -> Result<(), Error> {
|
|
let reply_string = format!("\
|
|
SquadQuest version {ver}\n\
|
|
Find the map here: {url}",
|
|
ver = env!("CARGO_PKG_VERSION"),
|
|
url = "not implemented yet!",
|
|
);
|
|
ctx.say(reply_string).await?;
|
|
Ok(())
|
|
}
|
|
|
|
pub async fn error_handler(error: poise::FrameworkError<'_, Data, Error>) {
|
|
eprintln!("ERROR:");
|
|
print_error_recursively(&error);
|
|
if let Some(ctx) = error.ctx() {
|
|
let response = match error {
|
|
poise::FrameworkError::Command { error, .. } => format!("Internal server error: {error}"),
|
|
_ => format!("Internal server error: {error}"),
|
|
};
|
|
if let Err(error) = ctx.send(CreateReply::default().content(response).ephemeral(true)).await {
|
|
eprintln!("Couldn't send error message: {error}");
|
|
}
|
|
}
|
|
}
|
|
|
|
fn print_error_recursively(error: &impl StdError) {
|
|
eprintln!("{error}");
|
|
if let Some(source) = error.source() {
|
|
eprintln!("source:");
|
|
print_error_recursively(&source);
|
|
}
|
|
}
|