aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel
Commit message (Collapse)AuthorAgeFilesLines
* Move unit tests into sourceZeyla Hellyer2018-08-011-0/+90
| | | | | | | | | 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 `impl AsRef<MessageId> for Message` (#355)Adelyn2018-07-251-0/+6
|
* Fix `ChannelId::send_message`'s dead linksacdenisSK2018-07-251-3/+3
|
* Fix some clippy lintsZeyla Hellyer2018-07-152-19/+18
| | | | | Some lints were not resolved due to causing API changes. Most lints in the framework were left unfixed.
* Fix doc links with no anchorZeyla Hellyer2018-07-111-0/+4
|
* Deprecate Message::guild_id()Zeyla Hellyer2018-07-091-14/+11
| | | | | Instead, using the structfield is preferred, since that comes from gateway events directly now anyway.
* Monomorphize all functionsZeyla Hellyer2018-07-046-21/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* feature: add guild_id to Message, per g250k changesChristopher F2018-06-171-0/+5
| | | | | | this allows stateless bots to drop the need for a channel->guild mapping (cherry picked from commit 74bb8fa5a3b4b5fd43559866b4627bf09484f6ae)
* Remove extraneous spaces at the end of linesZeyla Hellyer2018-06-172-6/+6
|
* Add methods to check whether `Message` is mentioning `User` (#323)Lakelezz2018-05-291-0/+15
|
* Add `Message::member` structfieldZeyla Hellyer2018-05-211-0/+3
| | | | | Adds the `Message::member` structfield, which contains a partial amount of member data (deaf and mute status, role IDs, and joined_at).
* Fix nsfw related docs (#299)Lakelezz2018-04-044-15/+15
|
* Refactor imports/exports to use nested groups and better formattingacdenisSK2018-03-295-9/+43
|
* Change the way ids and some enums are made (#295)Leah2018-03-232-39/+60
| | | | | This makes them easier to be found by tools like rls. Also update struct inits to use the shorthand version for `x: x`.
* Support sending files with an embed (#285)Brandon Lucier2018-03-041-5/+4
|
* Pad user discriminators in content_safe to 4 digitsMegumi Sonoda2018-02-231-1/+1
| | | | This brings the function in line with the 'tag' function for User models, and with the official Discord app experience and other libraries.
* Fix broken docs links caused by model mod changesZeyla Hellyer2018-01-312-2/+2
| | | | | Fix broken links caused by the `model` module changes in v0.5.0, which split up the module into sub-modules for better organization.
* Check message ID count in `delete_messages`Zeyla Hellyer2018-01-274-13/+29
| | | | | | In models' `delete_messages` methods, check the number of messages being deleted. If 0 or more than 100, return a `ModelError::BulkDeleteAmount`, as this amount would result in an invalid request.
* Add `Message::member`Zeyla Hellyer2018-01-271-0/+13
| | | | | | | | | Add a `member` function on `model::channel::Message` to retrieve a clone of the author's Member instance in the channel's guild. If the message was not sent in a guild, the guild could not be found in the cache, or the member instance could not be found in the cache, then `None` is returned.
* Fix compilation for some feature combinationsZeyla Hellyer2018-01-203-1/+7
|
* 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.
* 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.
* Move `VecMap` to `utils`acdenisSK2018-01-022-5/+3
| | | | This also fixes no-builder compilation
* Implement or derive Serialize on all modelsZeyla Hellyer2018-01-019-19/+86
|
* Add missing 'num' implementations on modelsZeyla Hellyer2017-12-272-0/+27
| | | | | | | Add missing 'num' implementations from the following models: - `channel::{ChannelType, MessageType}` - `gateway::GameType`
* Improve performance of builders even furtheracdenisSK2017-12-275-19/+21
| | | | | | By negating hashing altogether. The increase is around 1000-ish nanoseconds saved.
* Add `animated` to `Emoji` and `ReactionType`Zeyla Hellyer2017-12-201-2/+20
| | | | | | | | | | 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
|
* Break up the model moduleZeyla Hellyer2017-12-1610-34/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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}; ```
* Use `AsRef` instead of just `&MessageId`acdenisSK2017-12-061-1/+1
|
* 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
|
* Document that Reaction methods that hit the APIZeyla Hellyer2017-11-181-2/+8
| | | | | | | Documents that the following `model::Reaction` methods hit the REST API: - `message` - `users`
* Add a method to get a message from a reaction (#220)Maiddog2017-11-191-0/+10
|
* Fix doc-testsacdenisSK2017-11-161-2/+1
|
* Implement From<EmojiId | EmojiIdentifier> for ReactionType (#217)Fenhl2017-11-131-0/+18
|
* Change PrivateChannel::say to use `Display` (#214)Fenhl2017-11-121-1/+1
|
* Re-order use statements alphabeticallyZeyla Hellyer2017-11-118-27/+23
|
* Actually, change `NeverFails` to a void enumacdenisSK2017-11-051-1/+1
|
* Whoops. Add a `FromStr` impl for `ReactionType`acdenisSK2017-11-041-0/+27
|
* Merge v0.4.3acdenisSK2017-11-041-1/+1
|\
| * Rename `Guild::permissions_for`->`permissions_in`Zeyla Hellyer2017-10-301-1/+1
| | | | | | | | | | | | Rename `Guild::permissions_for` to `Guild::permissions_in`, deprecating `Guild::permissions_for` which is only an inline method to `permissions_in`.
* | Make the Client return a ResultZeyla Hellyer2017-11-033-4/+10
| | | | | | | | | | | | | | | | 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.
* | Merge v0.4.2acdenisSK2017-10-243-4/+19
|\|
| * Deprecate some text-only Channel methodsZeyla Hellyer2017-10-191-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some methods on `model::Channel` are only for text channels. Methods on Channel should be applicable to all channel types. Deprecates the following methods on `model::Channel`: - `create_reaction` - `delete_message` - `delete_reaction` - `edit_message` - `message` - `messages` - `reaction_users` - `say` - `send_files` - `send_message` - `unpin`
| * defer to `delete_message` if there's just one message to deleteacdenisSK2017-10-162-4/+8
| |
* | Remove `on_` prefix to EventHandler tymethodsZeyla Hellyer2017-10-222-4/+4
| | | | | | | | | | It was voted that the `on_` prefix is unnecessary, so these have been dropped.
* | Change CreateEmbed::field{,s} to not take buildersZeyla Hellyer2017-10-181-4/+19
| | | | | | | | | | | | | | | | | | Change the `field` and `fields` methods on `builder::CreateEmbed` to not accept a `CreateEmbedField` builder. The embed field builder realistically only had (and most likely, only will) have one optional argument, so the parameters may as well be on `CreateEmbed::field`.
* | Slightly improve performance of buildersZeyla Hellyer2017-10-185-35/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.