aboutsummaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Add a message cache API (#345)zeyla2018-07-091-0/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds an API for message caching. By default this caches 0 messages per channel. This can be customized when instantiating: ```rust use serenity::cache::{Cache, Settings}; let mut settings = Settings::new(); // Cache 10 messages per channel. settings.max_messages(10); let cache = Cache::new_with_settings(settings); ``` After instantiation: ```rust use serenity::cache::Cache; let mut cache = Cache::new(); cache.settings_mut().max_messages(10); ``` And during runtime through the global cache: ```rust use serenity::CACHE; CACHE.write().settings_mut().max_messages(10); ```
* Remove deprecated use of Colour associated methodsZeyla Hellyer2018-07-081-1/+1
|
* properly fix the is_nsfw check this timeacdenisSK2018-07-022-3/+4
|
* Simplify utils::is_nsfwZeyla Hellyer2018-07-021-1/+1
|
* Fix 'nsfw-' case in utils::is_nsfwZeyla Hellyer2018-07-021-1/+1
| | | | | | In the utils::is_nsfw function, an input of 'nsfw-' shouldn't return true. Discord's (previous) NSFW detection classified 'nsfw' and anything starting with 'nsfw-' - but not including - as NSFW.
* Fix utils::is_nsfw string slicingZeyla Hellyer2018-07-021-0/+14
| | | | | | | | | Removes string slicing on the input string, instead preferring to count chars and work off that information. Fixes channel names with unicode such as `général`. Fixes #342.
* Revamp `Args` from the ground-up (#326)Alex M. M2018-06-041-41/+46
|
* Add `Message::member` structfieldZeyla Hellyer2018-05-212-0/+32
| | | | | Adds the `Message::member` structfield, which contains a partial amount of member data (deaf and mute status, role IDs, and joined_at).
* Short-circuit on an erroracdenisSK2018-04-021-2/+4
| | | | And delegate most of is_empty checking to the internal parse function
* Fix formattingacdenisSK2018-02-241-1/+0
|
* Add tests for checking empty messages. (#281)Lakelezz2018-02-241-0/+70
|
* Fix testsacdenisSK2018-02-241-2/+3
|
* Fix RHS of testZeyla Hellyer2018-02-051-3/+0
|
* Remove `CreateEmbed::video` call from reverted PRZeyla Hellyer2018-02-051-1/+0
|
* Add video url specifier for CreateEmbed (#269)Andrej2018-02-021-2/+10
|
* Convert embed footers for CreateEmbed::from (#244)Derrick Lee2018-01-041-2/+10
|
* Remove builder re-export in utilsZeyla Hellyer2018-01-021-1/+1
|
* Implement or derive Serialize on all modelsZeyla Hellyer2018-01-011-1/+1
|
* Improve performance of builders even furtheracdenisSK2017-12-271-1/+1
| | | | | | By negating hashing altogether. The increase is around 1000-ish nanoseconds saved.
* Fix Guild::member_named and add teststahahawa2017-12-241-0/+103
| | | | | | | 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
* Fix `multiple_quoted` (#241)Lakelezz2017-12-241-13/+28
|
* Better support for multiple delimiters on `Args` (#239)Lakelezz2017-12-221-1/+291
|
* Add `animated` to `Emoji` and `ReactionType`Zeyla Hellyer2017-12-204-0/+21
| | | | | | | | | | 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)
* Actually fix `Args`'s `parse` and add a few tests (#236)Lakelezz2017-12-181-0/+50
|
* Fix `Guild` deser without `system_channel_id`Zeyla Hellyer2017-12-172-0/+30
| | | | | | | 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-2/+2
| | | | | Fix clippy lints and subsequently accept references for more function parameters.
* Break up the model moduleZeyla Hellyer2017-12-168-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 guild deserialization testsZeyla Hellyer2017-12-162-3/+5
| | | | | The tests for guild deserialization were failing due to new support for more fields, but old JSON test cases didn't have those fields.
* Fix deserialization of `Guild::application_id`Zeyla Hellyer2017-12-152-0/+7
| | | | | | | Fix the deserialization of the `Guild::application_id` structfield. Additionally, create a new ID type for it. A test has been added for this.
* impl From<&Path> for http::AttachmentTypeZeyla Hellyer2017-11-161-0/+18
|
* Fix parking_lot::{Mutex, RwLock} re-exportsZeyla Hellyer2017-11-091-2/+5
| | | | | | | | Fix the re-exports for `parking_lot::{Mutex, RwLock}` no longer functioning due to the conditional compilation gate removal (`parking_lot` is now always compiled). Tests have been updated to ensure the functionality of these re-exports.
* Merge v0.4.3acdenisSK2017-11-042-1/+3
|\
| * Fix doctests for a variety of feature targetsZeyla Hellyer2017-11-012-1/+3
| |
* | Slightly improve performance of buildersZeyla Hellyer2017-10-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Change `features` fields to be a Vec<String>Zeyla Hellyer2017-10-142-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-142-2/+2
|\|
| * Fix clippy lintsZeyla Hellyer2017-10-112-2/+2
| |
| * `to_owned` -> `to_string`acdenisSK2017-10-014-22/+22
| |
* | Switch to parking_lot::{Mutex, RwLock}Zeyla Hellyer2017-10-102-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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); ```
* | `to_owned` -> `to_string`acdenisSK2017-10-094-22/+22
|/
* Apply rustfmtZeyla Hellyer2017-09-181-12/+20
|
* Apply rustfmt + fix testsZeyla Hellyer2017-09-092-0/+2
|
* Clippy lintsZeyla Hellyer2017-08-183-5/+7
|
* Apply rustfmtZeyla Hellyer2017-08-181-20/+12
|
* Change the config a bit, and a few nitpicksacdenisSK2017-07-276-44/+54
|
* rustfmtacdenisSK2017-07-279-65/+73
|
* Fix the tests (#129)Bond-0092017-07-211-0/+1
|
* Fix testsacdenisSK2017-07-191-2/+6
|
* Fix doc testsacdenisSK2017-07-021-0/+1
|
* Fix no-feature testsZeyla Hellyer2017-06-248-104/+121
|