aboutsummaryrefslogtreecommitdiff
path: root/src/model/user.rs
Commit message (Collapse)AuthorAgeFilesLines
* Move unit tests into sourceZeyla Hellyer2018-08-011-0/+68
| | | | | | | | | 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.
* Add note about cache in UserId::get docsZeyla Hellyer2018-07-291-2/+3
|
* Fix some clippy lintsZeyla Hellyer2018-07-151-1/+1
| | | | | Some lints were not resolved due to causing API changes. Most lints in the framework were left unfixed.
* Monomorphize all functionsZeyla Hellyer2018-07-041-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* impl From<{,&'a }CurrentUser> for UserZeyla Hellyer2018-05-231-0/+24
| | | | | Implementation `From<CurrentUser> for User` and `From<&'a CurrentUser> for User`.
* 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)
* Move `VecMap` to `utils`acdenisSK2018-01-021-2/+2
| | | | This also fixes no-builder compilation
* Implement or derive Serialize on all modelsZeyla Hellyer2018-01-011-2/+2
|
* Improve performance of builders even furtheracdenisSK2017-12-271-3/+3
| | | | | | By negating hashing altogether. The increase is around 1000-ish nanoseconds saved.
* Fix typo (#235)Lakelezz2017-12-171-1/+1
|
* Break up the model moduleZeyla Hellyer2017-12-161-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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}; ```
* Change type of a couple Guild/PartialGuild fieldsZeyla Hellyer2017-12-151-14/+0
| | | | | | Changes the types of `Guild` and `PartialGuild`'s `default_message_notifications` and `mfa_level` structfields to be a bit more type-strong.
* Re-order use statements alphabeticallyZeyla Hellyer2017-11-111-6/+6
|
* Merge v0.4.3acdenisSK2017-11-041-6/+6
|\
| * Fix no-client cache testsZeyla Hellyer2017-11-011-6/+6
| | | | | | | | | | There were a few doctests in the cache module that relied on the client module, so instead feature-gate the doctests.
* | Make the Client return a ResultZeyla Hellyer2017-11-031-2/+5
| | | | | | | | | | | | | | | | 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.
* | Remove unwrapsacdenisSK2017-10-241-1/+1
| |
* | Merge v0.4.2acdenisSK2017-10-241-2/+22
|\|
| * Fix User::has_roleZeyla Hellyer2017-10-241-1/+5
| | | | | | | | | | | | | | | | | | Fix the return value of the function by properly checking whether the user has the role in the given guild. The function made the erraneous mistake of simply checking if the given guild had the role by Id, not whether the _member in the given guild_ had the role by Id.
| * Hash and do equality on just the id for `User`acdenisSK2017-10-151-1/+17
| |
| * Generate `Default` for CurrentUser and use it in `Cache::default`acdenisSK2017-10-081-1/+1
| |
| * Revert "Use the de-generification trick."acdenisSK2017-10-031-6/+4
| | | | | | | | Makes the compiliation time just a bit worse
| * Use the de-generification trick.acdenisSK2017-10-021-4/+6
| | | | | | | | Fixes #168
| * `to_owned` -> `to_string`acdenisSK2017-10-011-2/+2
| |
* | Remove `on_` prefix to EventHandler tymethodsZeyla Hellyer2017-10-221-3/+3
| | | | | | | | | | It was voted that the `on_` prefix is unnecessary, so these have been dropped.
* | Slightly improve performance of buildersZeyla Hellyer2017-10-181-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Builders would keep a `serde_json::Map<String, Value>`, which would require re-creating owned strings for the same parameter multiple times in some cases, depending on builder defaults and keying strategies. This commit uses a `std::collections::HashMap<&'static str, Value>` internally, and moves over values to a `serde_json::Map<String, Value>` when it comes time to sending them to the appropriate `http` module function. This saves the number of heap-allocated string creations on most builders, with specific performance increase on `builder::CreateMessage` and `builder::CreateEmbed` & co.
* | Switch to parking_lot::{Mutex, RwLock}Zeyla Hellyer2017-10-101-35/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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); ```
* | Generate `Default` for CurrentUser and use it in `Cache::default`acdenisSK2017-10-091-1/+1
| |
* | Revert "Use the de-generification trick."acdenisSK2017-10-091-6/+4
| | | | | | | | Makes the compiliation time just a bit worse
* | Use the de-generification trick.acdenisSK2017-10-091-4/+6
| | | | | | | | Fixes #168
* | `to_owned` -> `to_string`acdenisSK2017-10-091-2/+2
|/
* Fix User::tag and CurrentUser::tag discrim outputZeyla Hellyer2017-09-281-1/+1
| | | | | The output in a tag may result in "username#304" instead of the correct "username#0304".
* Refactor display impls for idsacdenisSK2017-09-241-4/+0
|
* Update bitflags, other dependenciesZeyla Hellyer2017-09-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Bitflags changed its macro codegen from creating constants to associated constants on structs. Upgrade path: Update code from: ```rust use serenity::model::permissions::{ADD_REACTIONS, MANAGE_MESSAGES}; foo(vec![ADD_REACTIONS, MANAGE_MESSAGES]); ``` to: ```rust use serenity::model::Permissions; foo(vec![Permissions::ADD_REACTIONS, Permissions::MANAGE_MESSAGES]); ```
* Apply rustfmtZeyla Hellyer2017-09-181-31/+15
|
* Fix compiles of a variety of feature combinationsZeyla Hellyer2017-09-181-2/+2
| | | | | This fixes compilation errors and warnings when compiling a mixture of non-default feature targets.
* match to map/?acdenisSK2017-09-041-4/+1
|
* Prevent malformed opus data from crashing the bot process (#149)Maiddog2017-08-271-29/+32
|
* Add ability to play DCA and Opus files. (#148)Maiddog2017-08-271-15/+30
|
* Revamp `RwLock` usage in the libacdenisSK2017-08-241-60/+44
| | | | Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
* Use cache when possible in UserId's get method (#146)Maiddog2017-08-221-1/+10
|
* Fix rustfmt lines that are too longZeyla Hellyer2017-08-181-1/+2
| | | | | Apparently rustfmt can't fix some of these, causing it to exit with 3 and therefore failing the build.
* Apply rustfmtZeyla Hellyer2017-08-181-7/+15
|
* Change the config a bit, and a few nitpicksacdenisSK2017-07-271-9/+7
|
* rustfmtacdenisSK2017-07-271-108/+78
|
* Remove the deprecated functionsacdenisSK2017-07-111-35/+0
| | | | It's already been enough time for people to migrate
* Make `User` and `Ban` comparable and hashableacdenisSK2017-07-101-1/+1
|
* Fix doc testsacdenisSK2017-07-021-52/+67
|
* Prevent Direct Messaging other bot usersZeyla Hellyer2017-06-261-0/+16
| | | | | | The API no longer allows bot users to Direct Message other bot users, so pre-emptively check that the recipient is not a bot. If it is, return a `ModelError::MessagingBot`.
* Fix CurrentUser::invite_urlKen Swenson2017-06-131-14/+61
| | | Use the client ID instead of the user ID.