mirror of
https://github.com/Noratrieb/discord-court-bot.git
synced 2026-01-14 09:55:02 +01:00
improvements
This commit is contained in:
parent
e851bd7449
commit
a2d7f73960
2 changed files with 22 additions and 18 deletions
|
|
@ -23,19 +23,11 @@ impl Debug for Handler {
|
|||
}
|
||||
}
|
||||
|
||||
pub enum Response {
|
||||
EphemeralStr(&'static str),
|
||||
Ephemeral(String),
|
||||
NoPermissions,
|
||||
}
|
||||
pub struct Response(pub String);
|
||||
|
||||
impl Display for Response {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::EphemeralStr(str) => f.write_str(str),
|
||||
Self::Ephemeral(str) => f.write_str(str),
|
||||
Self::NoPermissions => f.write_str("du häsch kei recht für da!"),
|
||||
}
|
||||
f.write_str(&self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -431,5 +423,17 @@ pub async fn listener(
|
|||
}
|
||||
|
||||
pub async fn error_handler(error: poise::FrameworkError<'_, Handler, Report>) {
|
||||
error!(?error, "Error during command execution");
|
||||
match error {
|
||||
poise::FrameworkError::MissingUserPermissions { ctx, .. } => {
|
||||
let _ = ctx.say("du häsch kei recht für da!").await;
|
||||
}
|
||||
poise::FrameworkError::GuildOnly { ctx } => {
|
||||
let _ = ctx
|
||||
.say("du chasch de command nur uf emene serve nutze!")
|
||||
.await;
|
||||
}
|
||||
err => {
|
||||
error!(?err, "Error during command execution");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ impl LawsuitCtx {
|
|||
Ok(room) => room,
|
||||
}
|
||||
}
|
||||
(None, None) => return Ok(Response::EphemeralStr(
|
||||
"Zuerst eine Kategorie für die Gerichtsräume festlegen mit `/lawsuit set_category`",
|
||||
(None, None) => return Ok(Response(
|
||||
"Zuerst eine Kategorie für die Gerichtsräume festlegen mit `/lawsuit set_category`".to_string(),
|
||||
)),
|
||||
};
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ impl LawsuitCtx {
|
|||
}
|
||||
});
|
||||
|
||||
Ok(Response::Ephemeral(format!(
|
||||
Ok(Response(format!(
|
||||
"ha eine ufgmacht im channel <#{}>",
|
||||
channel_id
|
||||
)))
|
||||
|
|
@ -147,7 +147,7 @@ impl LawsuitCtx {
|
|||
room: CourtRoom,
|
||||
) -> Result<Result<(), Response>> {
|
||||
if self.lawsuit.judge != user_id.into() && !permission_override {
|
||||
return Ok(Err(Response::NoPermissions));
|
||||
return Ok(Err(Response("du häsch kei recht für da!".to_string())));
|
||||
}
|
||||
|
||||
self.lawsuit.verdict = Some(verdict);
|
||||
|
|
@ -313,8 +313,8 @@ impl LawsuitCtx {
|
|||
}
|
||||
None => {
|
||||
// todo: remove the court room from the db
|
||||
return Ok(Err(Response::EphemeralStr(
|
||||
"i ha de channel für de prozess nöd gfunde",
|
||||
return Ok(Err(Response(
|
||||
"i ha de channel für de prozess nöd gfunde".to_string(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ impl LawsuitCtx {
|
|||
let channel_id = match channels.values().find(|c| c.name() == room_name) {
|
||||
Some(channel) => {
|
||||
if channel.parent_id != Some(category_id.into()) {
|
||||
return Ok(Err(Response::Ephemeral(format!(
|
||||
return Ok(Err(Response(format!(
|
||||
"de channel {room_name} isch i de falsche kategorie, man eh"
|
||||
))));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue