Make BotCommands::parse accept bot username as &str

Former-commit-id: 8dfb5268be
This commit is contained in:
Maybe Waffle 2022-10-05 09:52:00 +04:00
parent b061a21881
commit 466900ee46
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| {
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
/// `/cmd@username_of_the_bot`.
fn parse<N>(s: &str, bot_username: N) -> Result<Self, ParseError>
where
N: Into<String>;
fn parse(s: &str, bot_username: &str) -> Result<Self, ParseError>;
/// Returns descriptions of the commands suitable to be shown to the user
/// (for example when `/help` command is used).