Return whether command handled message

This commit is contained in:
Joscha 2023-02-27 12:41:49 +01:00
parent a6331d50b8
commit 4479126500
12 changed files with 142 additions and 47 deletions

View file

@ -50,12 +50,20 @@ where
B: HasDescriptions + Send,
E: From<conn::Error>,
{
async fn execute(&self, arg: &str, msg: &Message, ctx: &Context, bot: &mut B) -> Result<(), E> {
async fn execute(
&self,
arg: &str,
msg: &Message,
ctx: &Context,
bot: &mut B,
) -> Result<bool, E> {
if arg.trim().is_empty() {
let reply = self.formulate_reply(ctx, bot);
ctx.reply(msg.id, reply).await?;
Ok(true)
} else {
Ok(false)
}
Ok(())
}
}
@ -77,9 +85,9 @@ where
msg: &Message,
ctx: &Context,
bot: &mut B,
) -> Result<(), E> {
) -> Result<bool, E> {
let reply = self.formulate_reply(ctx, bot);
ctx.reply(msg.id, reply).await?;
Ok(())
Ok(true)
}
}

View file

@ -30,11 +30,13 @@ where
msg: &Message,
ctx: &Context,
_bot: &mut B,
) -> Result<(), E> {
) -> Result<bool, E> {
if arg.trim().is_empty() {
ctx.reply(msg.id, &self.0).await?;
Ok(true)
} else {
Ok(false)
}
Ok(())
}
}
@ -55,8 +57,8 @@ where
msg: &Message,
ctx: &Context,
_bot: &mut B,
) -> Result<(), E> {
) -> Result<bool, E> {
ctx.reply(msg.id, &self.0).await?;
Ok(())
Ok(true)
}
}

View file

@ -24,11 +24,13 @@ where
msg: &Message,
ctx: &Context,
_bot: &mut B,
) -> Result<(), E> {
) -> Result<bool, E> {
if arg.trim().is_empty() {
ctx.reply(msg.id, &self.0).await?;
Ok(true)
} else {
Ok(false)
}
Ok(())
}
}
@ -49,8 +51,8 @@ where
msg: &Message,
ctx: &Context,
_bot: &mut B,
) -> Result<(), E> {
) -> Result<bool, E> {
ctx.reply(msg.id, &self.0).await?;
Ok(())
Ok(true)
}
}

View file

@ -81,12 +81,20 @@ where
B: HasStartTime + Send,
E: From<conn::Error>,
{
async fn execute(&self, arg: &str, msg: &Message, ctx: &Context, bot: &mut B) -> Result<(), E> {
async fn execute(
&self,
arg: &str,
msg: &Message,
ctx: &Context,
bot: &mut B,
) -> Result<bool, E> {
if arg.trim().is_empty() {
let reply = self.formulate_reply(ctx, bot, false);
ctx.reply(msg.id, reply).await?;
Ok(true)
} else {
Ok(false)
}
Ok(())
}
}
@ -112,9 +120,9 @@ where
msg: &Message,
ctx: &Context,
bot: &mut B,
) -> Result<(), E> {
) -> Result<bool, E> {
let reply = self.formulate_reply(ctx, bot, args.connected);
ctx.reply(msg.id, reply).await?;
Ok(())
Ok(true)
}
}