ferrisgram/methods/
set_chat_administrator_custom_title.rs

1// WARNING: THIS CODE IS AUTOGENERATED.
2// DO NOT EDIT!!!
3
4#![allow(clippy::too_many_arguments)]
5use serde::Serialize;
6
7use crate::error::Result;
8use crate::Bot;
9
10impl Bot {
11    /// Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
12    /// <https://core.telegram.org/bots/api#setchatadministratorcustomtitle>
13    pub fn set_chat_administrator_custom_title(
14        &self,
15        chat_id: i64,
16        user_id: i64,
17        custom_title: String,
18    ) -> SetChatAdministratorCustomTitleBuilder {
19        SetChatAdministratorCustomTitleBuilder::new(self, chat_id, user_id, custom_title)
20    }
21}
22
23#[derive(Serialize)]
24pub struct SetChatAdministratorCustomTitleBuilder<'a> {
25    #[serde(skip)]
26    bot: &'a Bot,
27    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
28    pub chat_id: i64,
29    /// Unique identifier of the target user
30    pub user_id: i64,
31    /// New custom title for the administrator; 0-16 characters, emoji are not allowed
32    pub custom_title: String,
33}
34
35impl<'a> SetChatAdministratorCustomTitleBuilder<'a> {
36    pub fn new(bot: &'a Bot, chat_id: i64, user_id: i64, custom_title: String) -> Self {
37        Self {
38            bot,
39            chat_id,
40            user_id,
41            custom_title,
42        }
43    }
44
45    pub fn chat_id(mut self, chat_id: i64) -> Self {
46        self.chat_id = chat_id;
47        self
48    }
49
50    pub fn user_id(mut self, user_id: i64) -> Self {
51        self.user_id = user_id;
52        self
53    }
54
55    pub fn custom_title(mut self, custom_title: String) -> Self {
56        self.custom_title = custom_title;
57        self
58    }
59
60    pub async fn send(self) -> Result<bool> {
61        let form = serde_json::to_value(&self)?;
62        self.bot
63            .get("setChatAdministratorCustomTitle", Some(&form))
64            .await
65    }
66}