diff options
| author | Austin Hellyer <[email protected]> | 2016-11-09 20:37:22 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-09 20:37:22 -0800 |
| commit | ab1bc3fe821c9b66d4e348bf10ce3a096195bdba (patch) | |
| tree | bca39ceedc4cb4380d79bb286ae89fe9a7f354e5 | |
| parent | Correctly decode Group channel IDs (diff) | |
| download | serenity-ab1bc3fe821c9b66d4e348bf10ce3a096195bdba.tar.xz serenity-ab1bc3fe821c9b66d4e348bf10ce3a096195bdba.zip | |
Add a Feature enum
Features are handed by Discord to guilds that meet requirements which
are most likely realistically arbitrary.
The 3 features at this moment are:
- INVITE_SPLASH
- VANITY_URL
- VIP_REGIONS
On decoding of the two guild structs, map these string values to enum
variants.
| -rw-r--r-- | definitions/enums/feature.yml | 24 | ||||
| -rw-r--r-- | definitions/structs/guild.yml | 3 | ||||
| -rw-r--r-- | definitions/structs/live_guild.yml | 2 | ||||
| -rw-r--r-- | src/model/guild.rs | 2 |
4 files changed, 28 insertions, 3 deletions
diff --git a/definitions/enums/feature.yml b/definitions/enums/feature.yml new file mode 100644 index 0000000..a9f935c --- /dev/null +++ b/definitions/enums/feature.yml @@ -0,0 +1,24 @@ +--- +name: Feature +description: > + A special feature, such as for VIP guilds, that a [`Guild`] has had granted to + them. + + [`Guild`]: struct.Guild.html +variants: + - variant: InviteSplash + description: > + The guild can set a custom [`splash`][`Guild::splash`] image on invite + URLs. + + [`Guild::splash`]: struct.Guild.html#structfield.splash + name: INVITE_SPLASH + - variant: VanityUrl + description: > + The guild can set a Vanity URL, which is a custom-named permanent invite + URL. + name: VANITY_URL + - variant: VipRegions + description: > + The guild has access to VIP voice channel regions. + name: VIP_REGIONS diff --git a/definitions/structs/guild.yml b/definitions/structs/guild.yml index 44567e3..40518e0 100644 --- a/definitions/structs/guild.yml +++ b/definitions/structs/guild.yml @@ -22,7 +22,8 @@ fields: type: hashmap - name: features array: true - type: string + custom: Feature::decode_str + type: Feature - name: icon optional: true type: string diff --git a/definitions/structs/live_guild.yml b/definitions/structs/live_guild.yml index ed2aafe..0b027ca 100644 --- a/definitions/structs/live_guild.yml +++ b/definitions/structs/live_guild.yml @@ -18,7 +18,7 @@ fields: type: hashmap - name: features array: true - type: string + type: Feature - name: icon optional: true type: string diff --git a/src/model/guild.rs b/src/model/guild.rs index e8aff56..460f5ca 100644 --- a/src/model/guild.rs +++ b/src/model/guild.rs @@ -309,7 +309,7 @@ impl LiveGuild { channels: public_channels, default_message_notifications: req!(try!(remove(&mut map, "default_message_notifications")).as_u64()), emojis: try!(remove(&mut map, "emojis").and_then(decode_emojis)), - features: try!(remove(&mut map, "features").and_then(|v| decode_array(v, into_string))), + features: try!(remove(&mut map, "features").and_then(|v| decode_array(v, Feature::decode_str))), icon: try!(opt(&mut map, "icon", into_string)), id: id, joined_at: try!(remove(&mut map, "joined_at").and_then(into_string)), |