-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Panini-Devs/0.0.1-staging-changes
Pagination of warning command
- Loading branch information
Showing
8 changed files
with
182 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ pub mod git; | |
pub mod messages; | ||
pub mod models; | ||
pub mod modlog; | ||
pub mod on_error; | ||
pub mod paginate; | ||
pub mod types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use tracing::error; | ||
|
||
use crate::FrameworkError; | ||
|
||
use super::messages; | ||
|
||
pub async fn on_error(error: FrameworkError<'_>) { | ||
match error { | ||
FrameworkError::Setup { .. } | FrameworkError::EventHandler { .. } => {} | ||
FrameworkError::Command { ctx, .. } => { | ||
let reply = | ||
messages::error_reply("Oh no! There's a problem in executing this command.", true); | ||
if let Err(why) = ctx.send(reply).await { | ||
if why.to_string().contains("40060") { | ||
// Interaction has already been acknowledged. | ||
return; | ||
} | ||
|
||
error!("Couldn't send reply: {why:?}"); | ||
} | ||
} | ||
FrameworkError::CommandPanic { ctx, .. } => { | ||
let reply = messages::error_reply( | ||
"Oh no! A panic occurred whilst executing this command.", | ||
true, | ||
); | ||
if let Err(why) = ctx.send(reply).await { | ||
error!("Couldn't send reply: {:?}", why); | ||
} | ||
} | ||
FrameworkError::ArgumentParse { .. } | ||
| poise::FrameworkError::CommandStructureMismatch { .. } => {} | ||
FrameworkError::MissingBotPermissions { | ||
missing_permissions, | ||
ctx, | ||
.. | ||
} => { | ||
let permissions = missing_permissions | ||
.iter() | ||
.map(|permission| permission.to_string()) | ||
.collect::<Vec<String>>() | ||
.join(", "); | ||
|
||
let reply = messages::error_reply( | ||
format!("Oh no! I'm missing the following permission(s): `{permissions}`"), | ||
true, | ||
); | ||
if let Err(why) = ctx.send(reply).await { | ||
error!("Couldn't send reply: {:?}", why); | ||
} | ||
} | ||
FrameworkError::NsfwOnly { ctx, .. } => { | ||
let reply = messages::error_reply( | ||
"Sorry, but I can only execute this command in a NSFW channel.", | ||
true, | ||
); | ||
if let Err(why) = ctx.send(reply).await { | ||
error!("Couldn't send reply: {:?}", why); | ||
} | ||
} | ||
_ => {} | ||
} | ||
} |