Files
twilight
twilight_builders
twilight_cache
twilight_cache_inmemory
twilight_cache_trait
twilight_command_parser
twilight_gateway
twilight_http
client
ratelimiting
request
channel
guild
user
twilight_lavalink
twilight_mention
twilight_model
channel
gateway
guild
invite
oauth
user
voice
twilight_standby
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::request::prelude::*;
use twilight_model::{
    channel::ReactionType,
    id::{ChannelId, MessageId},
};

/// Delete one reaction by a user on a message.
pub struct DeleteReaction<'a> {
    channel_id: ChannelId,
    emoji: String,
    fut: Option<Pending<'a, ()>>,
    http: &'a Client,
    message_id: MessageId,
    target_user: String,
}

impl<'a> DeleteReaction<'a> {
    pub(crate) fn new(
        http: &'a Client,
        channel_id: ChannelId,
        message_id: MessageId,
        emoji: ReactionType,
        target_user: impl Into<String>,
    ) -> Self {
        Self {
            channel_id,
            emoji: super::format_emoji(emoji),
            fut: None,
            http,
            message_id,
            target_user: target_user.into(),
        }
    }

    fn start(&mut self) -> Result<()> {
        self.fut.replace(Box::pin(self.http.verify(Request::from(
            Route::DeleteReaction {
                channel_id: self.channel_id.0,
                emoji: self.emoji.clone(),
                message_id: self.message_id.0,
                user: self.target_user.clone(),
            },
        ))));

        Ok(())
    }
}

poll_req!(DeleteReaction<'_>, ());