From 8dfb5268bec63a3cebd67a7e27c5cd18432f6e97 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Wed, 5 Oct 2022 09:52:00 +0400 Subject: [PATCH] Make `BotCommands::parse` accept bot username as `&str` --- src/dispatching/handler_ext.rs | 2 +- src/utils/command.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/dispatching/handler_ext.rs b/src/dispatching/handler_ext.rs index f73dfb0a..932d5079 100644 --- a/src/dispatching/handler_ext.rs +++ b/src/dispatching/handler_ext.rs @@ -90,6 +90,6 @@ where { dptree::entry().chain(dptree::filter_map(move |message: Message, me: Me| { let bot_name = me.user.username.expect("Bots must have a username"); - message.text().and_then(|text| C::parse(text, bot_name).ok()) + message.text().and_then(|text| C::parse(text, &bot_name).ok()) })) } diff --git a/src/utils/command.rs b/src/utils/command.rs index 49dec198..c0f9cd2c 100644 --- a/src/utils/command.rs +++ b/src/utils/command.rs @@ -218,9 +218,7 @@ pub trait BotCommands: Sized { /// /// `bot_username` is required to parse commands like /// `/cmd@username_of_the_bot`. - fn parse(s: &str, bot_username: N) -> Result - where - N: Into; + fn parse(s: &str, bot_username: &str) -> Result; /// Returns descriptions of the commands suitable to be shown to the user /// (for example when `/help` command is used).