Struct teloxide::utils::command::CommandDescriptions
source · pub struct CommandDescriptions<'a> { /* private fields */ }
Expand description
Command descriptions that can be shown to the user (e.g. as a part of
/help
message)
Most of the time you don’t need to create this struct yourself as it’s
returned from BotCommands::descriptions
.
Implementations§
source§impl<'a> CommandDescriptions<'a>
impl<'a> CommandDescriptions<'a>
sourcepub const fn new(descriptions: &'a [CommandDescription<'a>]) -> Self
pub const fn new(descriptions: &'a [CommandDescription<'a>]) -> Self
Creates new CommandDescriptions
from a list of command descriptions.
sourcepub fn global_description(self, global_description: &'a str) -> Self
pub fn global_description(self, global_description: &'a str) -> Self
Sets the global description of these commands.
sourcepub fn username(self, bot_username: &'a str) -> Self
pub fn username(self, bot_username: &'a str) -> Self
Sets the username of the bot.
After this method is called, returned instance of
CommandDescriptions
will append @bot_username
to all commands.
This is useful in groups, to disambiguate commands for different bots.
Examples
use teloxide::utils::command::{CommandDescription, CommandDescriptions};
let descriptions = CommandDescriptions::new(&[
CommandDescription { prefix: "/", command: "start", description: "start this bot" },
CommandDescription { prefix: "/", command: "help", description: "show this message" },
]);
assert_eq!(descriptions.to_string(), "/start — start this bot\n/help — show this message");
assert_eq!(
descriptions.username("username_of_the_bot").to_string(),
"/start@username_of_the_bot — start this bot\n/help@username_of_the_bot — show this \
message"
);
sourcepub fn username_from_me(self, me: &'a Me) -> CommandDescriptions<'a>
pub fn username_from_me(self, me: &'a Me) -> CommandDescriptions<'a>
Sets the username of the bot.
This is the same as username
, but uses value returned from get_me
method to get the username.
Trait Implementations§
source§impl<'a> Clone for CommandDescriptions<'a>
impl<'a> Clone for CommandDescriptions<'a>
source§fn clone(&self) -> CommandDescriptions<'a>
fn clone(&self) -> CommandDescriptions<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more