initial rewrite in rust & moderation commands
Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
parent
b17e357b75
commit
45403e9d9b
53 changed files with 3297 additions and 2820 deletions
42
src/handlers/error.rs
Normal file
42
src/handlers/error.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
use crate::consts::COLORS;
|
||||
use crate::Data;
|
||||
|
||||
use color_eyre::eyre::Report;
|
||||
use log::*;
|
||||
use poise::serenity_prelude::Timestamp;
|
||||
use poise::FrameworkError;
|
||||
|
||||
pub async fn handle(error: poise::FrameworkError<'_, Data, Report>) {
|
||||
match error {
|
||||
FrameworkError::Setup { error, .. } => error!("Error setting up client!\n{error:#?}"),
|
||||
|
||||
FrameworkError::Command { error, ctx } => {
|
||||
error!("Error in command {}:\n{error:?}", ctx.command().name);
|
||||
ctx.send(|c| {
|
||||
c.embed(|e| {
|
||||
e.title("Something went wrong!")
|
||||
.description("oopsie")
|
||||
.timestamp(Timestamp::now())
|
||||
.color(COLORS["orange"])
|
||||
})
|
||||
})
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
|
||||
FrameworkError::EventHandler {
|
||||
error,
|
||||
ctx: _,
|
||||
event,
|
||||
framework: _,
|
||||
} => {
|
||||
error!("Error while handling event {}:\n{error:?}", event.name());
|
||||
}
|
||||
|
||||
error => {
|
||||
if let Err(e) = poise::builtins::on_error(error).await {
|
||||
error!("Unhandled error occured:\n{e:#?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue