Update README.md

This commit is contained in:
Hirrolot 2022-04-02 15:51:59 +06:00
parent 5000c4cec4
commit 56c1c55f88

View file

@ -125,7 +125,7 @@ Commands are strongly typed and defined declaratively, similar to how we define
([Full](examples/simple_commands.rs)) ([Full](examples/simple_commands.rs))
```rust,no_run ```rust,no_run
use teloxide::{prelude::*, utils::command::BotCommand}; use teloxide::{prelude::*, utils::command::BotCommands};
use std::error::Error; use std::error::Error;
@ -139,7 +139,7 @@ async fn main() {
teloxide::commands_repl(bot, answer, Command::ty()).await; teloxide::commands_repl(bot, answer, Command::ty()).await;
} }
#[derive(BotCommand, Clone)] #[derive(BotCommands, Clone)]
#[command(rename = "lowercase", description = "These commands are supported:")] #[command(rename = "lowercase", description = "These commands are supported:")]
enum Command { enum Command {
#[command(description = "display this text.")] #[command(description = "display this text.")]
@ -156,7 +156,9 @@ async fn answer(
command: Command, command: Command,
) -> Result<(), Box<dyn Error + Send + Sync>> { ) -> Result<(), Box<dyn Error + Send + Sync>> {
match command { match command {
Command::Help => bot.send_message(message.chat.id, Command::descriptions().to_string()).await?, Command::Help => {
bot.send_message(message.chat.id, Command::descriptions().to_string()).await?
}
Command::Username(username) => { Command::Username(username) => {
bot.send_message(message.chat.id, format!("Your username is @{}.", username)).await? bot.send_message(message.chat.id, format!("Your username is @{}.", username)).await?
} }