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
50
use rive_models::{emoji::Emoji, payload::CreateEmojiPayload};

use crate::prelude::*;

impl Client {
    /// Fetch an emoji by its ID.
    pub async fn fetch_emoji(&self, id: impl Into<String>) -> Result<Emoji> {
        Ok(self
            .client
            .get(ep!(self, "/custom/emoji/{}", id.into()))
            .auth(&self.authentication)
            .send()
            .await?
            .process_error()
            .await?
            .json()
            .await?)
    }

    /// Create an emoji by its Autumn upload id.
    pub async fn create_new_emoji(
        &self,
        id: impl Into<String>,
        payload: CreateEmojiPayload,
    ) -> Result<Emoji> {
        Ok(self
            .client
            .put(ep!(self, "/custom/emoji/{}", id.into()))
            .json(&payload)
            .auth(&self.authentication)
            .send()
            .await?
            .process_error()
            .await?
            .json()
            .await?)
    }

    /// Delete an emoji by its id
    pub async fn delete_emoji(&self, id: impl Into<String>) -> Result<()> {
        self.client
            .delete(ep!(self, "/custom/emoji/{}", id.into()))
            .auth(&self.authentication)
            .send()
            .await?
            .process_error()
            .await?;
        Ok(())
    }
}