refactor!: use poise 0.6.1
This commit is contained in:
parent
203ba111cc
commit
7252ced3cb
16 changed files with 700 additions and 512 deletions
|
@ -3,8 +3,8 @@ use crate::Data;
|
|||
|
||||
use color_eyre::eyre::Report;
|
||||
use log::*;
|
||||
use poise::serenity_prelude::Timestamp;
|
||||
use poise::FrameworkError;
|
||||
use poise::serenity_prelude::{CreateEmbed, Timestamp};
|
||||
use poise::{CreateReply, FrameworkError};
|
||||
|
||||
pub async fn handle(error: FrameworkError<'_, Data, Report>) {
|
||||
match error {
|
||||
|
@ -12,23 +12,23 @@ pub async fn handle(error: FrameworkError<'_, Data, Report>) {
|
|||
error, framework, ..
|
||||
} => {
|
||||
error!("Error setting up client! Bailing out");
|
||||
framework.shard_manager().lock().await.shutdown_all().await;
|
||||
framework.shard_manager().shutdown_all().await;
|
||||
|
||||
panic!("{error}")
|
||||
}
|
||||
|
||||
FrameworkError::Command { error, ctx } => {
|
||||
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["red"])
|
||||
})
|
||||
})
|
||||
.await
|
||||
.ok();
|
||||
|
||||
let embed = CreateEmbed::new()
|
||||
.title("Something went wrong!")
|
||||
.description("oopsie")
|
||||
.timestamp(Timestamp::now())
|
||||
.color(COLORS["red"]);
|
||||
|
||||
let reply = CreateReply::default().embed(embed);
|
||||
|
||||
ctx.send(reply).await.ok();
|
||||
}
|
||||
|
||||
FrameworkError::EventHandler {
|
||||
|
@ -36,13 +36,17 @@ pub async fn handle(error: FrameworkError<'_, Data, Report>) {
|
|||
ctx: _,
|
||||
event,
|
||||
framework: _,
|
||||
..
|
||||
} => {
|
||||
error!("Error while handling event {}:\n{error:?}", event.name());
|
||||
error!(
|
||||
"Error while handling event {}:\n{error:?}",
|
||||
event.snake_case_name()
|
||||
);
|
||||
}
|
||||
|
||||
error => {
|
||||
if let Err(e) = poise::builtins::on_error(error).await {
|
||||
error!("Unhandled error occured:\n{e:#?}");
|
||||
error!("Unhandled error occurred:\n{e:#?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue