aboutsummaryrefslogtreecommitdiff
path: root/src/model
Commit message (Collapse)AuthorAgeFilesLines
...
* Account for guild owners in member hierarchy checkZeyla Hellyer2018-01-271-0/+15
| | | | | | When using `Guild::greater_member_hierarchy`, check if both user IDs are the same (returning None) or if one of them is the guild owner, in which case the guild owner's ID is returned.
* Fix compilation for some feature combinationsZeyla Hellyer2018-01-203-1/+7
|
* Fix no-cache compilationacdenisSK2018-01-201-0/+1
|
* Add an `EditMessage` builderZeyla Hellyer2018-01-186-36/+32
| | | | | | When editing messages, not all fields are applicable. Attachments, TTS, and reactions are not applicable. To help with this distinction, separate message editing into a different builder.
* Create unset member instances on presence updatesZeyla Hellyer2018-01-171-0/+19
| | | | | | | | If a presence update for a guild comes in and their associated member instance is not present (e.g. in a large guild that wasn't member chunked), then create one with the infomation known out of the presence update. This includes their user information, guild ID, nickname, and roles, but not their `deaf`, `joined_at`, and `mute` state.
* Fix no-model compiler warningsZeyla Hellyer2018-01-103-3/+3
|
* Fix docs for User::has_roleNikita Pekin2018-01-101-3/+4
| | | | | | | | Update the docs for `User::has_role` to reflect that `Into<GuildContainer>` is only implemented for `PartialGuild`, `GuildId`, and `u64`, not `Guild`. (cherry picked from commit 00deef894ec458ac8abff914ed864ea63c47eda6)
* Allow channels to be moved in and out of a category (#248)Kyle Clemens2018-01-083-8/+12
|
* Fix compilationZeyla Hellyer2018-01-062-6/+5
|
* Add some role position hierarchy checksZeyla Hellyer2018-01-063-8/+36
|
* Add Guild::greater_member_hierarchyZeyla Hellyer2018-01-061-0/+47
| | | | | Add a function to determine which of two members has the higher role hierarchy.
* Add Member::highest_role_infoZeyla Hellyer2018-01-061-0/+40
|
* Further generic-ify `reaction_users` `after` paramZeyla Hellyer2018-01-056-49/+52
| | | | | | | | | | | | | | | | | | Further generic-ify the `after` parameter on the `reaction_users` method of the following structs: - `ChannelId` - `Group` - `GuildChannel` - `Message` - `Channel` - `GuildChannel` Do this by changing the `U` trait bound from `Into<UserId>` to `Into<Option<UserId>>`. This resolves problems determining types when passing `None` as the argument, as reported in #247.
* Fix permission overwrites in permission buildingZeyla Hellyer2018-01-051-1/+11
| | | | | | | | | | | | | | While building permissions in the `Guild::permissions_in` function - which is relied upon by most model functions to check CurrentUser permissions - the channel overwrites of the given channel were iterated over incorrectly. The channel overwrites were iterated over in a non-specified order, resulting in overwrites being applied in a random order. However, Discord operates by applying permissions from a down-top order: role ID 0 is below role ID 1, which is below role ID 2, etc. This means that prior to applying permissions we must first sort by position so that lower positioned roles are iterated over first.
* Remove GameType::WatchingZeyla Hellyer2018-01-031-32/+0
| | | | | | According to [this commit], the game type has been removed. [this commit]: https://github.com/discordapp/discord-api-docs/commit/50999182f307ffda9ac7208a48570586ea446c08#diff-b307d936b736f302bc7cc153f0d8a0a3L779
* Move `VecMap` to `utils`acdenisSK2018-01-023-7/+5
| | | | This also fixes no-builder compilation
* Implement or derive Serialize on all modelsZeyla Hellyer2018-01-0126-115/+442
|
* Add missing 'num' implementations on modelsZeyla Hellyer2017-12-273-0/+40
| | | | | | | Add missing 'num' implementations from the following models: - `channel::{ChannelType, MessageType}` - `gateway::GameType`
* Improve performance of builders even furtheracdenisSK2017-12-2710-31/+33
| | | | | | By negating hashing altogether. The increase is around 1000-ish nanoseconds saved.
* Fix Guild::member_named and add teststahahawa2017-12-241-8/+15
| | | | | | | Use rfind, in case there's more '#' in username than just the discriminator Split at pos+1 instead of pos and remove the trailing '#' in the split.0 (Name) Fix bug with parsing
* Update model to include new voice regions (#240)Ken Swenson2017-12-231-0/+8
|
* Add `animated` to `Emoji` and `ReactionType`Zeyla Hellyer2017-12-202-2/+27
| | | | | | | | | | Adds an animated structfield to `Emoji` and `ReactionType`'s `Custom` variant, which defaults to false if not present. A test has been added for deserializing it, taken from a REST API GET Emojis response. (cherry picked from commit 5286949f424e824784344ebb7b7af4e52fb819c3)
* Add variant adapters to Channel (#238)Timo2017-12-201-0/+133
|
* GatewayEvent: don't unwrap deserializationsZeyla Hellyer2017-12-191-1/+2
| | | | | This commit makes GatewayEvent no longer unwrap Dispatch deserializations, and instead Try? it away.
* Fix `Guild` deser without `system_channel_id`Zeyla Hellyer2017-12-171-4/+4
| | | | | | | Fix the deserialization of `model::guild::Guild` when `Guild::system_channel_id` is not present. Additionally, add a test case for this.
* Default serde on a couple Ready structfieldsZeyla Hellyer2017-12-171-6/+8
| | | | | | | Have serde default on the `presences` and `private_channels` structfields of `Ready`. Some JSON serializers might leave these out when serializing if they're empty, so resolve this by simply defaulting to empty maps.
* Fix typo (#235)Lakelezz2017-12-171-1/+1
|
* Fix doc-tests and `single_zc`acdenisSK2017-12-171-1/+1
|
* Fix most clippy lints, take more refeerncesZeyla Hellyer2017-12-164-8/+9
| | | | | Fix clippy lints and subsequently accept references for more function parameters.
* Break up the model moduleZeyla Hellyer2017-12-1630-319/+391
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `model` module has historically been one giant module re-exporting all of the model types, which is somewhere around 100 types. This can be a lot to look at for a new user and somewhat overwhelming, especially with a large number of fine-grained imports from the module. The module is now neatly split up into submodules, mostly like it has been internally since the early versions of the library. The submodules are: - application - channel - error - event - gateway - guild - id - invite - misc - permissions - prelude - user - voice - webhook Each submodule contains types that are "owned" by the module. For example, the `guild` submodule contains, but not limited to, Emoji, AuditLogsEntry, Role, and Member. `channel` contains, but not limited to, Attachment, Embed, Message, and Reaction. Upgrade path: Instead of glob importing the models via `use serenity::model::*;`, instead glob import via the prelude: ```rust use serenity::model::prelude::*; ``` Instead of importing from the root model module: ```rust use serenity::model::{Guild, Message, OnlineStatus, Role, User}; ``` instead import from the submodules like so: ```rust use serenity::model::channel::Message; use serenity::model::guild::{Guild, Role}; use serenity::model::user::{OnlineStatus, User}; ```
* Revamp the internals of `Args`acdenisSK2017-12-161-3/+3
| | | | Fixes #180, however this partially breaks `single_zc` and `multiple_quoted`, but since they're minor it's better to fix them later for now.
* Fix deserialization of `Guild::application_id`Zeyla Hellyer2017-12-152-2/+4
| | | | | | | Fix the deserialization of the `Guild::application_id` structfield. Additionally, create a new ID type for it. A test has been added for this.
* Change type of a couple Guild/PartialGuild fieldsZeyla Hellyer2017-12-153-20/+44
| | | | | | Changes the types of `Guild` and `PartialGuild`'s `default_message_notifications` and `mfa_level` structfields to be a bit more type-strong.
* Add missing fields to Guild modelZeyla Hellyer2017-12-151-0/+46
| | | | | | | | Adds the following missing fields to the Guild model: - `application_id` - `explicit_content_filter` - `system_channel_id`
* Use a macro to generate FromStr implsacdenisSK2017-12-101-177/+92
|
* Merge branch 'branch-v0.4.5' into v0.5.0Zeyla Hellyer2017-12-091-2/+2
|\
| * Fix remaining deserializersZeyla Hellyer2017-12-091-2/+2
| | | | | | | | | | | | Following up on the recent commit to fix the snowflake types' deserializers, this commit fixes the rest of the library's usage of deserializers in the same manner.
| * Fix snowflake deserializerZeyla Hellyer2017-12-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes snowflake deserializers (ChannelId, UserId, etc.) by switching from a usage of `deserialize_u64` to `deserialize_any`. Our usage of `deserialize_u64` was incorrect and the erroneous behaviour was fixed in serde_json v1.0.8. We were essentially telling serde that the received type was a u64, when in fact it can be multiple types (strings, u64, or an i64 just in case). This resulted in errors like: ``` Client error: Json(ErrorImpl { code: Message("invalid type: string \"317727377985634305\", expected identifier"), line: 1, column: 100 }) ``` Due to this, simple operations such as even connecting a client failed.
* | Fix snowflake deserializerZeyla Hellyer2017-12-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes snowflake deserializers (ChannelId, UserId, etc.) by switching from a usage of `deserialize_u64` to `deserialize_any`. Our usage of `deserialize_u64` was incorrect and the erroneous behaviour was fixed in serde_json v1.0.8. We were essentially telling serde that the received type was a u64, when in fact it can be multiple types (strings, u64, or an i64 just in case). This resulted in errors like: ``` Client error: Json(ErrorImpl { code: Message("invalid type: string \"317727377985634305\", expected identifier"), line: 1, column: 100 }) ``` Due to this, simple operations such as even connecting a client failed. (cherry picked from commit 77f462ea2044ef7d2d12fd1289ea75a6a33cb5dd)
* | Fall back to `str::parse` on `ChannelId` as wellacdenisSK2017-12-061-7/+56
| | | | | | | | Also give an actual error type for `Channel` too.
* | Make the comment for the `AsRef` impl more clearacdenisSK2017-12-061-1/+3
| |
* | Use `AsRef` instead of just `&MessageId`acdenisSK2017-12-061-1/+1
| |
* | Add the `VIEW_AUDIT_LOG` permission (#229)Lakelezz2017-12-041-0/+8
| |
* | Tune down repetition with a macroacdenisSK2017-11-301-56/+31
| |
* | Convert from macro to ? (#226)Mei Boudreau2017-11-231-1/+1
| |
* | Fix no-gateway compilationZeyla Hellyer2017-11-201-3/+1
| |
* | Implement Deserialize for {,Gateway,Voice}EventZeyla Hellyer2017-11-191-149/+480
| | | | | | | | | | | | | | | | | | | | | | Implement Deserialize for `model::event::GatewayEvent` and `model::event::VoiceEvent`, and derive it for `model::event::Event`. Due to the natural potential slowness of deserializing into`Event` (attempting to deserialize into each variant until successful), a function named `model::event::deserialize_event_with_type` is provided for quickly deserializing into a known type if the dispatch type is known.
* | Add `model::Reaction::user`Zeyla Hellyer2017-11-181-3/+13
| | | | | | | | | | | | Add a `user` method to `Reaction::user`, which retrieves the User who made the reaction. This will check the cache for the user and, if either disabled or not found, falls back to hitting the REST API.
* | Add `model::Reaction::channel`Zeyla Hellyer2017-11-181-0/+15
| | | | | | | | | | | | Adds a `channel` method to `model::Reaction`, which retrieves the channel the reaction was made in from the Cache, falling back to hitting the REST API if one was not found (or the cache is disabled).
* | Alphabetize Reaction methodsZeyla Hellyer2017-11-181-14/+14
| |