use crate::Client;
use crate::errors::Result;
use crate::raw::functions;
use crate::types::{BotCommand, BotCommandScope};
#[must_use = "a request does nothing until it is awaited"]
pub struct GetBotCommands<'a> {
client: &'a Client,
scope: BotCommandScope,
language_code: String,
}
impl Client {
pub fn get_bot_commands(&self) -> GetBotCommands<'_> {
GetBotCommands { client: self, scope: BotCommandScope::Default, language_code: String::new() }
}
}
impl GetBotCommands<'_> {
pub fn scope(mut self, scope: BotCommandScope) -> Self {
self.scope = scope;
self
}
pub fn language_code(mut self, language_code: impl Into<String>) -> Self {
self.language_code = language_code.into();
self
}
async fn send(self) -> Result<Vec<BotCommand>> {
let request = functions::bots::GetBotCommands {
scope: self.scope.write(self.client).await?,
lang_code: self.language_code,
};
Ok(self.client.invoke(&request).await?.into_iter().map(BotCommand::parse).collect())
}
}
into_future!(GetBotCommands, Vec<BotCommand>);