Make BotCommands::parse accept bot username as &str

This commit is contained in:
Maybe Waffle 2022-10-05 09:52:00 +04:00
parent f7684fef29
commit 8dfb5268be
2 changed files with 2 additions and 4 deletions

View file

@ -90,6 +90,6 @@ where
{ {
dptree::entry().chain(dptree::filter_map(move |message: Message, me: Me| { dptree::entry().chain(dptree::filter_map(move |message: Message, me: Me| {
let bot_name = me.user.username.expect("Bots must have a username"); 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())
})) }))
} }

View file

@ -218,9 +218,7 @@ pub trait BotCommands: Sized {
/// ///
/// `bot_username` is required to parse commands like /// `bot_username` is required to parse commands like
/// `/cmd@username_of_the_bot`. /// `/cmd@username_of_the_bot`.
fn parse<N>(s: &str, bot_username: N) -> Result<Self, ParseError> fn parse(s: &str, bot_username: &str) -> Result<Self, ParseError>;
where
N: Into<String>;
/// Returns descriptions of the commands suitable to be shown to the user /// Returns descriptions of the commands suitable to be shown to the user
/// (for example when `/help` command is used). /// (for example when `/help` command is used).