twilight_http/request/channel/reaction/
delete_all_reaction.rs1use super::RequestReactionType;
2use crate::{
3 client::Client,
4 error::Error,
5 request::{Request, TryIntoRequest},
6 response::{marker::EmptyBody, Response, ResponseFuture},
7 routing::Route,
8};
9use std::future::IntoFuture;
10use twilight_model::id::{
11 marker::{ChannelMarker, MessageMarker},
12 Id,
13};
14
15#[must_use = "requests must be configured and executed"]
17pub struct DeleteAllReaction<'a> {
18 channel_id: Id<ChannelMarker>,
19 emoji: &'a RequestReactionType<'a>,
20 http: &'a Client,
21 message_id: Id<MessageMarker>,
22}
23
24impl<'a> DeleteAllReaction<'a> {
25 pub(crate) const fn new(
26 http: &'a Client,
27 channel_id: Id<ChannelMarker>,
28 message_id: Id<MessageMarker>,
29 emoji: &'a RequestReactionType<'a>,
30 ) -> Self {
31 Self {
32 channel_id,
33 emoji,
34 http,
35 message_id,
36 }
37 }
38}
39
40impl IntoFuture for DeleteAllReaction<'_> {
41 type Output = Result<Response<EmptyBody>, Error>;
42
43 type IntoFuture = ResponseFuture<EmptyBody>;
44
45 fn into_future(self) -> Self::IntoFuture {
46 let http = self.http;
47
48 match self.try_into_request() {
49 Ok(request) => http.request(request),
50 Err(source) => ResponseFuture::error(source),
51 }
52 }
53}
54
55impl TryIntoRequest for DeleteAllReaction<'_> {
56 fn try_into_request(self) -> Result<Request, Error> {
57 Ok(Request::from_route(&Route::DeleteMessageSpecificReaction {
58 channel_id: self.channel_id.get(),
59 message_id: self.message_id.get(),
60 emoji: self.emoji,
61 }))
62 }
63}