aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel/message.rs
Commit message (Collapse)AuthorAgeFilesLines
* 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-041-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* 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).
* Change the way ids and some enums are made (#295)Leah2018-03-231-17/+29
| | | | | This makes them easier to be found by tools like rls. Also update struct inits to use the shorthand version for `x: x`.
* 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.
* 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.
* Add an `EditMessage` builderZeyla Hellyer2018-01-181-10/+6
| | | | | | 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-051-8/+8
| | | | | | | | | | | | | | | | | | 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.
* Implement or derive Serialize on all modelsZeyla Hellyer2018-01-011-2/+2
|
* Add missing 'num' implementations on modelsZeyla Hellyer2017-12-271-0/+17
| | | | | | | Add missing 'num' implementations from the following models: - `channel::{ChannelType, MessageType}` - `gateway::GameType`
* Improve performance of builders even furtheracdenisSK2017-12-271-1/+1
| | | | | | By negating hashing altogether. The increase is around 1000-ish nanoseconds saved.
* Break up the model moduleZeyla Hellyer2017-12-161-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 doc-testsacdenisSK2017-11-161-2/+1
|
* Re-order use statements alphabeticallyZeyla Hellyer2017-11-111-9/+5
|
* 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.
* Slightly improve performance of buildersZeyla Hellyer2017-10-181-1/+3
| | | | | | | | | | | | | | | 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.
* Update to account for changes made in 0.4.1acdenisSK2017-10-141-2/+2
|\
| * Fix clippy lintsZeyla Hellyer2017-10-111-2/+2
| |
| * Revert "Use the de-generification trick."acdenisSK2017-10-031-5/+1
| | | | | | | | Makes the compiliation time just a bit worse
| * Use the de-generification trick.acdenisSK2017-10-021-1/+5
| | | | | | | | Fixes #168
| * `to_owned` -> `to_string`acdenisSK2017-10-011-1/+1
| |
* | Switch to parking_lot::{Mutex, RwLock}Zeyla Hellyer2017-10-101-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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); ```
* | Revert "Use the de-generification trick."acdenisSK2017-10-091-5/+1
| | | | | | | | Makes the compiliation time just a bit worse
* | Use the de-generification trick.acdenisSK2017-10-091-1/+5
| | | | | | | | Fixes #168
* | `to_owned` -> `to_string`acdenisSK2017-10-091-1/+1
|/
* Update bitflags, other dependenciesZeyla Hellyer2017-09-211-6/+6
| | | | | | | | | | | | | | | | | | | | | | | 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-16/+13
|
* 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.
* Apply rustfmt + fix testsZeyla Hellyer2017-09-091-0/+1
|
* Add ability to play DCA and Opus files. (#148)Maiddog2017-08-271-13/+16
|
* Revamp `RwLock` usage in the libacdenisSK2017-08-241-16/+13
| | | | Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
* Fix tests (#145)Maiddog2017-08-221-0/+1
|
* Move builtin framework impl to its own moduleZeyla Hellyer2017-08-191-2/+2
| | | | | | | | | | | | | | | | | The framework is now moved in its entirity to the `framework` module, with the `Framework` trait currently on its own and the builtin implementation provided. The builtin implementation has been renamed to "Standard". Upgrade path: Rename the `BuiltinFramework` import to `StandardFramework`. Instead of importing builtin framework items from `serenity::framework`, import them from `serenity::framework::standard`. This is the beginning to #60. The root `framework` module (non-standard implementation) will be built more by the time it's closed.
* Apply rustfmtZeyla Hellyer2017-08-181-13/+16
|
* Change the config a bit, and a few nitpicksacdenisSK2017-07-271-7/+6
|
* rustfmtacdenisSK2017-07-271-51/+53
|
* Fix is_own codeZeyla Hellyer2017-07-251-1/+1
| | | | | The current user ID is located on the `user` structfield in the cache, and is not directly on the cache.
* Actually, rename it to "is_own" insteadacdenisSK2017-07-261-1/+1
|
* Add a util function for checking if a message was sent by the bot or someone ↵acdenisSK2017-07-261-0/+6
| | | | else
* Fix #130acdenisSK2017-07-221-1/+2
| | | | Removed action support from the builtin one as well, due to it adding some uneccassery complexity and it being only asked upon by one user
* Remove the deprecated functionsacdenisSK2017-07-111-10/+0
| | | | It's already been enough time for people to migrate
* Fix doc testsacdenisSK2017-07-021-3/+5
|
* Docs fixesmei2017-06-271-1/+1
|
* Make Message::nonce a serde_json::ValueZeyla Hellyer2017-06-231-1/+3
| | | | | | | | | | | | | | | | | | Nonces can actually be almost anything - including booleans - so just use a Value to represent it since very few users will need it. This fixes errors like: ``` WARN:serenity::internal::ws_impl: (╯°□°)╯︵ ┻━┻ Error decoding: {"t":"MESSAGE_CREATE","s":12187872,"op":0,"d":{"type":0,"tts":false,"timestamp":"2017-06-01T01:00:00.000000+00:00","pinned":false,"nonce":"","mentions":[{"username":"redacted","id":"redacted","discriminator":"redacted","avatar":"redacted"}],"mention_roles":[],"mention_everyone":false,"id":"redacted","embeds":[],"edited_timestamp":null,"content":"redacted","channel_id":"redacted","author":{"username":"redacted","id":"redacted","discriminator":"redacted","bot":true,"avatar":"redacted"},"attachments":[]}} ERROR:serenity::client: Shard handler received err: Json(ErrorImpl { code: Message("Unknown i64 value: "), line: 0, column: 0 }) ``` and: ``` WARN:serenity::internal::ws_impl: (╯°□°)╯︵ ┻━┻ Error decoding: {"t":"MESSAGE_CREATE","s":1001192,"op":0,"d":{"type":0,"tts":false,"timestamp":"2017-06-01T01:01:01.000000+00:00","pinned":false,"nonce":true,"mentions":[],"mention_roles":[],"mention_everyone":false,"id":"redacted","embeds":[],"edited_timestamp":null,"content":"bork","channel_id":"redacted","author":{"username":"redacted","id":"redacted","discriminator":"redacted","bot":true,"avatar":"redacted"},"attachments":[]}} ERROR:serenity::client: Shard handler received err: Json(ErrorImpl { code: Message("invalid type: boolean `true`, expected identifier"), line: 0, column: 0 }) ```
* Switch from #[doc(hidden)] to pub(crate)alex2017-06-141-6/+3
| | | | | | Switch from using `#[doc(hidden)]` to hide some internal functions to `pub(crate)`. The library now requires rustc 1.18.
* Fix negative nonces failing to deserializeZeyla Hellyer2017-06-101-1/+1
| | | | | | | | | | Negative message nonces caused deserialization errors, as serde would not deserialize integers into strings. To fix this, change `Message::nonce` into an `Option<Snowflake>` from an `Option<String>`. This new `Snowflake` is a wrapper around an `i64`. Use a new `I64Visitor` to deserialize i64s, u64s, and strs into the wanted i64.
* Deprecate Client::login, add Client::newZeyla Hellyer2017-06-061-1/+1
|
* Use chrono for struct timestamp fieldsZeyla Hellyer2017-06-061-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Chrono is easier to use than timestamped strings, so they should be automatically deserialized and available for the user, instead of having the user deserialize the strings themselves. These fields have been changed to use a type of `DateTime<FixedOffset>`: - `ChannelPinsUpdateEvent.last_pin_timestamp` - `Group.last_pin_timestamp` - `Guild.joined_at` - `GuildChannel.last_pin_timestamp` - `Invite.created_at` - `Member.joined_at` - `Message.edited_timestamp - `Message.timestamp` - `MessageUpdateEvent.edited_timestamp` - `MessageUpdateEvent.timestamp` - `PrivateChannel.last_pin_timestamp` `Member.joined_at` is now also an `Option`. Previously, if a Guild Member Update was received for a member not in the cache, a new Member would be instantiated with a default String value. This is incorrect behaviour, and has now been replaced with being set to `None` in that case. Id methods' `created_at()` method now return a `chrono::NaiveDateTime` instead of a `time::Timespec`, and `User::created_at` has been updated to reflect that. Additionally, drop `time` as a direct dependency and use chrono for internals.