Skip to content

Commit f23d8db

Browse files
authored
Fix Role::position deserialisation on current (#3032)
This was already fixed on next with #2716, but this ports that to current.
1 parent 0d48282 commit f23d8db

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/model/guild/role.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ use crate::internal::prelude::*;
1212
use crate::model::prelude::*;
1313
use crate::model::utils::is_false;
1414

15+
fn minus1_as_0<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<u16, D::Error> {
16+
i16::deserialize(deserializer).map(|val| if val == -1 { 0 } else { val as u16 })
17+
}
18+
1519
/// Information about a role within a guild.
1620
///
1721
/// A role represents a set of permissions, and can be attached to one or multiple users. A role has
@@ -57,6 +61,7 @@ pub struct Role {
5761
/// position is higher.
5862
///
5963
/// The `@everyone` role is usually either `-1` or `0`.
64+
#[serde(deserialize_with = "minus1_as_0")]
6065
pub position: u16,
6166
/// The tags this role has. It can be used to determine if this role is a special role in this
6267
/// guild such as guild subscriber role, or if the role is linked to an [`Integration`] or a

0 commit comments

Comments
 (0)