ferrisgram/methods/
delete_forum_topic.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 delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success.
12    /// <https://core.telegram.org/bots/api#deleteforumtopic>
13    pub fn delete_forum_topic(
14        &self,
15        chat_id: i64,
16        message_thread_id: i64,
17    ) -> DeleteForumTopicBuilder {
18        DeleteForumTopicBuilder::new(self, chat_id, message_thread_id)
19    }
20}
21
22#[derive(Serialize)]
23pub struct DeleteForumTopicBuilder<'a> {
24    #[serde(skip)]
25    bot: &'a Bot,
26    /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
27    pub chat_id: i64,
28    /// Unique identifier for the target message thread of the forum topic
29    pub message_thread_id: i64,
30}
31
32impl<'a> DeleteForumTopicBuilder<'a> {
33    pub fn new(bot: &'a Bot, chat_id: i64, message_thread_id: i64) -> Self {
34        Self {
35            bot,
36            chat_id,
37            message_thread_id,
38        }
39    }
40
41    pub fn chat_id(mut self, chat_id: i64) -> Self {
42        self.chat_id = chat_id;
43        self
44    }
45
46    pub fn message_thread_id(mut self, message_thread_id: i64) -> Self {
47        self.message_thread_id = message_thread_id;
48        self
49    }
50
51    pub async fn send(self) -> Result<bool> {
52        let form = serde_json::to_value(&self)?;
53        self.bot.get("deleteForumTopic", Some(&form)).await
54    }
55}