telers/methods/get_chat_administrators.rs
1use crate::client::Bot;
2use serde::Serialize;
3/// Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of [`crate::types::ChatMember`] objects.
4/// # Documentation
5/// <https://core.telegram.org/bots/api#getchatadministrators>
6/// # Returns
7/// - `Box<[crate::types::ChatMember]>`
8#[derive(Clone, Debug, Serialize)]
9pub struct GetChatAdministrators {
10 /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
11 pub chat_id: crate::types::ChatIdKind,
12}
13impl GetChatAdministrators {
14 /// Creates a new `GetChatAdministrators`.
15 ///
16 /// # Arguments
17 /// * `chat_id` - Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
18 #[must_use]
19 pub fn new<T0: Into<crate::types::ChatIdKind>>(chat_id: T0) -> Self {
20 Self {
21 chat_id: chat_id.into(),
22 }
23 }
24
25 /// Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
26 #[must_use]
27 pub fn chat_id<T: Into<crate::types::ChatIdKind>>(self, val: T) -> Self {
28 let mut this = self;
29 this.chat_id = val.into();
30 this
31 }
32}
33impl super::TelegramMethod for GetChatAdministrators {
34 type Method = Self;
35 type Return = Box<[crate::types::ChatMember]>;
36
37 fn build_request<Client>(self, _bot: &Bot<Client>) -> super::Request<Self::Method> {
38 super::Request::new("getChatAdministrators", self, None)
39 }
40}