aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild/mod.rs
Commit message (Collapse)AuthorAgeFilesLines
* Make `Region`s `Japan`-variant lowercase.upstreamLakelezz2018-11-131-1/+1
|
* Use `to_`- and `as_`-methods instead of `get` and `find` on Id newtypesLakelezz2018-08-121-2/+2
|
* Fix all the dead links in the docsErk-2018-08-091-55/+52
|
* Add From impls for Game, generify Game paramsZeyla Hellyer2018-08-011-1/+0
| | | | | Add more `impl From<T> for Game` implementations, and make `Into<Game>` trait bounds for all function parameters accepting a Game.
* Move unit tests into sourceZeyla Hellyer2018-08-011-0/+107
| | | | | | | | | Move the unit tests into the relevant source files. There's no need for them to be seprate, especially when the `tests` directory is meant to be for integration tests. The deserialization tests that include JSON files are still in the `tests` dir, along with the public prelude re-export tests.
* Fix doc links with no anchorZeyla Hellyer2018-07-111-0/+3
|
* Monomorphize all functionsZeyla Hellyer2018-07-041-7/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit monomorphizes all functions, turning functions like: ```rust fn foo<T: Into<Bar>>(baz: T) { baz = baz.into(); // function here } ``` Into functions like: ```rust fn foo<T: Into<Bar>>(baz: T) { _foo(baz.into()) } fn _foo(baz: Bar) { // function here } ``` This avoids binary bloat and improves build times, by reducing the amount of code duplication.
* Change the way ids and some enums are made (#295)Leah2018-03-231-53/+81
| | | | | This makes them easier to be found by tools like rls. Also update struct inits to use the shorthand version for `x: x`.
* Add 'Get Guild Vanity Url' endpointZeyla Hellyer2018-02-091-0/+10
| | | | Docs: <https://github.com/discordapp/discord-api-docs/commit/98f6643703012d2f3780ba730ce1191120f85dcd>
* Reduce number of clones in the libraryZeyla Hellyer2018-01-271-16/+18
|
* Add functions to reorder a guild's channelsZeyla Hellyer2018-01-271-0/+10
| | | | | Add `http::edit_guild_channel_positions`, `Guild::reorder_channels`, and `GuildId::reorder_channels`.
* 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 no-cache compilationacdenisSK2018-01-201-0/+1
|
* Allow channels to be moved in and out of a category (#248)Kyle Clemens2018-01-081-3/+4
|
* Fix compilationZeyla Hellyer2018-01-061-1/+1
|
* Add some role position hierarchy checksZeyla Hellyer2018-01-061-0/+17
|
* Add Guild::greater_member_hierarchyZeyla Hellyer2018-01-061-0/+47
| | | | | Add a function to determine which of two members has the higher role hierarchy.
* 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.
* Implement or derive Serialize on all modelsZeyla Hellyer2018-01-011-7/+13
|
* 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
|
* 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.
* Fix most clippy lints, take more refeerncesZeyla Hellyer2017-12-161-4/+4
| | | | | Fix clippy lints and subsequently accept references for more function parameters.
* Break up the model moduleZeyla Hellyer2017-12-161-2/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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}; ```
* Fix deserialization of `Guild::application_id`Zeyla Hellyer2017-12-151-2/+2
| | | | | | | 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-151-4/+42
| | | | | | 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`
* Re-order use statements alphabeticallyZeyla Hellyer2017-11-111-5/+5
|
* Whoops. Add a `FromStr` impl for `ReactionType`acdenisSK2017-11-041-4/+4
|
* Merge v0.4.3acdenisSK2017-11-041-27/+81
|\
| * Rename `Guild::permissions_for`->`permissions_in`Zeyla Hellyer2017-10-301-3/+14
| | | | | | | | | | | | Rename `Guild::permissions_for` to `Guild::permissions_in`, deprecating `Guild::permissions_for` which is only an inline method to `permissions_in`.
| * Guild::has_perms: use Guild::member_permissionsZeyla Hellyer2017-10-301-22/+14
| | | | | | | | | | | | Make `Guild`'s internal method `has_perms` go through `Guild::member_permissions` to check permissions, since all method that use it don't need channel-specific permissions.
| * Add Guild::member_permissionsZeyla Hellyer2017-10-301-0/+51
| | | | | | | | | | | | Add a method on the Guild for calculating only a member's guild-only permissions, not including the permissions for either the default channel or any specific channel.
* | Make the Client return a ResultZeyla Hellyer2017-11-031-1/+1
| | | | | | | | | | | | | | | | The client now returns a Result in preparation of a future commit. Upgrade path: Handle the case of an error via pattern matching, or unwrap the Result.
* | Fix audit logs a bitacdenisSK2017-11-011-1/+6
| |
* | Merge v0.4.2acdenisSK2017-10-241-0/+20
|\|
| * Implement changing a role's position (#201)Ken Swenson2017-10-191-0/+20
| |
* | Remove `on_` prefix to EventHandler tymethodsZeyla Hellyer2017-10-221-1/+1
| | | | | | | | | | It was voted that the `on_` prefix is unnecessary, so these have been dropped.
* | Fix some compilation feature targets, fix lintsZeyla Hellyer2017-10-171-1/+5
| |
* | Change `features` fields to be a Vec<String>Zeyla Hellyer2017-10-141-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When Discord adds new features, the Feature enum will not be able to serialize the new values until updated, causing the entire Guild deserialization to fail. Due to the fact that these features can be added at any time, the `features` vector on Guild and PartialGuild have been changed to be a `Vec<String>`. Upgrade path: Instead of matching on variants of Feature like so: ```rust use serenity::model::Feature; for feature in guild.features { if feature == Feature::VipRegions { // do work with this info } } ``` Instead opt to check the string name of the feature: ```rust for feature in guild.features { if feature == "VIP_REGIONS" { // do work with this info } } ```
* | Update to account for changes made in 0.4.1acdenisSK2017-10-141-19/+220
|\|
| * Fix clippy lintsZeyla Hellyer2017-10-111-28/+28
| |
| * Variety of methods to search for `Member`. (#187)Lakelezz2017-10-101-12/+218
| |
| * Find `Member` via substrings, allow case-insensitivity on ↵Lakelezz2017-10-071-4/+54
| | | | | | | | `members_containing` and `members_starting_with` (#184)
| * Help-commands filtering and Member-prefix-search (#182)Lakelezz2017-10-071-0/+18
| |
| * Revert "Use the de-generification trick."acdenisSK2017-10-031-20/+10
| | | | | | | | Makes the compiliation time just a bit worse
| * Use the de-generification trick.acdenisSK2017-10-021-10/+20
| | | | | | | | Fixes #168
| * `to_owned` -> `to_string`acdenisSK2017-10-011-2/+2
| |
* | Switch to parking_lot::{Mutex, RwLock}Zeyla Hellyer2017-10-101-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch to the `parking_lot` crate's implementations of `std::sync::Mutex` and `std::sync::RwLock`, which are more efficient. A writeup on why `parking_lot` is more efficient can be read here: <https://github.com/Amanieu/parking_lot> Upgrade path: Modify `mutex.lock().unwrap()` usage to `mutex.lock()` (not needing to unwrap or handle a result), and `rwlock.read().unwrap()`/`rwlock.write().unwrap()` usage to `rwlock.read()` and `rwlock.write()`. For example, modify: ```rust use serenity::CACHE; println!("{}", CACHE.read().unwrap().user.id); ``` to: ```rust use serenity::CACHE; println!("{}", CACHE.read().user.id); ```
* | Find `Member` via substrings, allow case-insensitivity on ↵Lakelezz2017-10-091-4/+54
| | | | | | | | `members_containing` and `members_starting_with` (#184)