Skip to content

Commit e00a91f

Browse files
nwerosamaGnomedDev
authored andcommitted
Add roles field to create and edit emoji (#3095)
1 parent fa7a3fb commit e00a91f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/model/guild/guild_id.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,14 @@ impl GuildId {
318318
builder.execute(http, self).await
319319
}
320320

321-
/// Creates an emoji in the guild with a name and base64-encoded image.
321+
/// Creates an emoji in the guild with a name and base64-encoded image and set of roles.
322322
///
323323
/// The name of the emoji must be at least 2 characters long and can only contain alphanumeric
324324
/// characters and underscores.
325325
///
326+
/// The emoji will only be visible by anyone that has the role(s) defined in the `roles`
327+
/// parameter.
328+
///
326329
/// Requires the [Create Guild Expressions] permission.
327330
///
328331
/// # Examples
@@ -343,17 +346,21 @@ impl GuildId {
343346
http: &Http,
344347
name: &str,
345348
image: &str,
349+
roles: Option<Vec<RoleId>>,
346350
reason: Option<&str>,
347351
) -> Result<Emoji> {
348352
#[derive(serde::Serialize)]
349353
struct CreateEmoji<'a> {
350354
name: &'a str,
351355
image: &'a str,
356+
#[serde(skip_serializing_if = "Option::is_none")]
357+
roles: Option<Vec<RoleId>>,
352358
}
353359

354360
let body = CreateEmoji {
355361
name,
356362
image,
363+
roles,
357364
};
358365

359366
http.create_emoji(self, &body, reason).await
@@ -565,12 +572,15 @@ impl GuildId {
565572
builder.execute(http, self).await
566573
}
567574

568-
/// Edits an [`Emoji`]'s name in the guild.
575+
/// Edits an [`Emoji`]'s name and roles in the guild.
569576
///
570577
/// **Note**: If the emoji was created by the current user, requires either the [Create Guild
571578
/// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild
572579
/// Expressions] permission is required.
573580
///
581+
/// If an emoji was edited to be visible by the selected roles in the parameter, only those with
582+
/// it can only see the emoji.
583+
///
574584
/// # Errors
575585
///
576586
/// Returns [`Error::Http`] if the current user lacks permission, or if an emoji with the given
@@ -583,15 +593,19 @@ impl GuildId {
583593
http: &Http,
584594
emoji_id: EmojiId,
585595
name: &str,
596+
roles: Option<Vec<RoleId>>,
586597
reason: Option<&str>,
587598
) -> Result<Emoji> {
588599
#[derive(serde::Serialize)]
589600
struct EditEmoji<'a> {
590601
name: &'a str,
602+
#[serde(skip_serializing_if = "Option::is_none")]
603+
roles: Option<Vec<RoleId>>,
591604
}
592605

593606
let map = EditEmoji {
594607
name,
608+
roles,
595609
};
596610

597611
http.edit_emoji(self, emoji_id, &map, reason).await

0 commit comments

Comments
 (0)