telers/methods/delete_my_commands.rs
1use crate::client::Bot;
2use serde::Serialize;
3/// Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns `true` on success.
4/// # Documentation
5/// <https://core.telegram.org/bots/api#deletemycommands>
6/// # Returns
7/// - `bool`
8#[derive(Clone, Debug, Serialize)]
9pub struct DeleteMyCommands {
10 /// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to [`crate::types::BotCommandScopeDefault`].
11 #[serde(skip_serializing_if = "Option::is_none")]
12 pub scope: Option<crate::types::BotCommandScope>,
13 /// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub language_code: Option<Box<str>>,
16}
17impl DeleteMyCommands {
18 /// Creates a new `DeleteMyCommands`.
19 ///
20 /// # Notes
21 /// Use builder methods to set optional fields.
22 #[must_use]
23 pub fn new() -> Self {
24 Self {
25 scope: None,
26 language_code: None,
27 }
28 }
29
30 /// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to [`crate::types::BotCommandScopeDefault`].
31 #[must_use]
32 pub fn scope<T: Into<crate::types::BotCommandScope>>(self, val: T) -> Self {
33 let mut this = self;
34 this.scope = Some(val.into());
35 this
36 }
37
38 /// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to [`crate::types::BotCommandScopeDefault`].
39 #[must_use]
40 pub fn scope_option<T: Into<crate::types::BotCommandScope>>(self, val: Option<T>) -> Self {
41 let mut this = self;
42 this.scope = val.map(Into::into);
43 this
44 }
45
46 /// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
47 #[must_use]
48 pub fn language_code<T: Into<Box<str>>>(self, val: T) -> Self {
49 let mut this = self;
50 this.language_code = Some(val.into());
51 this
52 }
53
54 /// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
55 #[must_use]
56 pub fn language_code_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
57 let mut this = self;
58 this.language_code = val.map(Into::into);
59 this
60 }
61}
62impl Default for DeleteMyCommands {
63 fn default() -> Self {
64 Self::new()
65 }
66}
67impl super::TelegramMethod for DeleteMyCommands {
68 type Method = Self;
69 type Return = bool;
70
71 fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
72 super::Request::new("deleteMyCommands", self, None)
73 }
74}