aboutsummaryrefslogtreecommitdiff
path: root/src/model
Commit message (Collapse)AuthorAgeFilesLines
...
* More widely support no-cache method compilesAustin Hellyer2016-11-253-115/+160
| | | | | | | Conditional compiles with the 'methods' feature enabled - but the 'cache' feature disabled - were supported, but methods would call an empty function to check if the current user has permissions. Instead, put these function calls behind macros which check for feature cfgs.
* Catch some clippy lintsAustin Hellyer2016-11-251-3/+0
|
* Move events into their own moduleAustin Hellyer2016-11-253-757/+765
| | | | | | | | | | | | | | | | | | | | The events were cluttering the `model` module, and so are now moved into their own `model::event` module. As users should not usually have to work with events all that much - only currently in some rarely used event handlers - this change should not be much more effort to import from. i.e.: ```rs use serenity::model::event::ChannelPinsAckEvent; ``` vs. the now-old: ```rs use serenity::model::ChannelPinsAckEvent; ```
* Rename PublicChannel to GuildChannelAustin Hellyer2016-11-257-33/+33
|
* Fix permission check on Message::deleteAustin Hellyer2016-11-251-8/+2
|
* Rename the `http` module to `rest`Austin Hellyer2016-11-256-99/+99
|
* Allow compiling with only either cache or methodsAustin Hellyer2016-11-246-68/+103
| | | | | | | | | Some of the methods relied on the cache being present. Now, these methods only conditionally require the cache to be compiled and present. The cache was mainly used for checking if the current user had permission to perform operations.
* Rename guild structs to Guild and PartialGuildAustin Hellyer2016-11-246-27/+27
|
* Change the CACHE to be an RwLockAustin Hellyer2016-11-226-20/+20
| | | | | | | | | | | | | | | | | | The global Cache used to be an Arc<Mutex>, however the issue is that it could only be opened for reading or writing once at a time. With an RwLock, multiple readers can access the Cache at once, while only one Writer may at once. This will allow users to be able to have multiple Readers open at once, which should ease some of the pains with working with the Cache. Upgrade path: Modify all uses of the CACHE from: `CACHE.lock().unwrap()` to `CACHE.read().unwrap()` if reading from the Cache (most use cases), or `CACHE.write().unwrap()` to write to it.
* Rename the State to CacheAustin Hellyer2016-11-228-62/+62
|
* Don't unnecessarily borrow some if-letsAustin Hellyer2016-11-212-2/+3
|
* Add created_at method to Ids and UserAustin Hellyer2016-11-212-0/+16
| | | | Returns a Timespec of when the Id (or User) was created.
* Add Member::roles()Austin Hellyer2016-11-201-0/+20
| | | | | | | The roles method will search through the state and find full role data for the member. This is essentially a shorthand for it. This does perform a clone of the role data, but this will be optimized in the future.
* Rework contextual presence methodsAustin Hellyer2016-11-191-5/+5
| | | | | | | | | Rework the methods to accept strings and games directly, rather than Optional values. Instead, use the new `reset_presence` to set a clean status, or `set_presence` for more fine-grained control. In addition, `Game::playing` and `Game::streaming` now accept `&str`s rather than Strings.
* Rename state methods from find_ to get_Austin Hellyer2016-11-194-9/+8
| | | | | | | | | | For consistency with the rest of the library, rename the methods prefixed with `find_` to `get_`. The past logic was that items are "found", as they may or may not exist. With get, the expectation is that it is _always_ there, i.e. over REST. However, this is inconsistent, and "get"ting over REST can fail for other reasons.
* Fix cond. compile across multiple feature targetsAustin Hellyer2016-11-191-2/+2
| | | | | | | | Fixes conditional compilation across multiple combinations of feature targets, where it was assumed a second feature would be enabled by something that requires a feature to be enabled. This also fixes an EOF compilation error on no-feature builds.
* Don't send embed on message edits if emptyAustin Hellyer2016-11-191-1/+1
|
* Add PublicChannel::guild()Austin Hellyer2016-11-191-0/+9
| | | | | This will search the state for the channel's associated guild, acting as a shortcut.
* Add GuildId::to_channelAustin Hellyer2016-11-181-0/+8
|
* Register friend suggestion eventsAustin Hellyer2016-11-181-0/+27
|
* A bit of docsAustin Hellyer2016-11-182-21/+29
|
* Allow Id/u64 equality comparisonsAustin Hellyer2016-11-171-1/+13
| | | | | | | | | | | | | | This will allow comparing, for example, a `ChannelId` with a `u64` directly, bypassing the need to do something like: ```rust let channel_id = ChannelId(7); assert!(channel_id.0 == 7); // can now be replaced with: assert!(channel_id == 7); ```
* Decode discriminators as stringsAustin Hellyer2016-11-171-7/+2
| | | | | While this will use a slightly higher amount of memory, it will be easier for users to use.
* Add DELETE/PUT guild member roleAustin Hellyer2016-11-161-5/+36
| | | | | | | | | | Adds support for `DELETE /guilds/:guild_id/members/:user_id/roles/:role_id` and `PUT /guilds/:guild_id/members/:user_id/roles/:role_id`, which are routes to add or remove individual roles to a guild member. The `Member::add_role` and `Member::remove_role` methods will edit in-place.
* Accepting invites only works for user accountsAustin Hellyer2016-11-161-3/+43
| | | | | They do not work for bot users. So return a `ClientError::InvalidOperationAsBot` if someone tries to.
* Add message edit/edit_message rich embedsAustin Hellyer2016-11-151-5/+17
|
* Add send_message rich embedsAustin Hellyer2016-11-152-2/+11
|
* Add state/framework/etc. conditional compile flagsAustin Hellyer2016-11-1511-24/+165
| | | | | | | | | | | | | | | This adds conditional compilation for the following features, in addition to the voice conditional compilation flag: - extras (message builder) - framework - methods - state These 4 are enabled _by default_, while the `voice` feature flag is disabled. Disabling the state will allow incredibly low-memory bots.
* Decode embed/role colours into Colour structAustin Hellyer2016-11-142-10/+2
| | | | | | This is for a little bit of ergonomics, and is of such a minute cost that it is worth it to just directly decode the u32's received for Role/Embed colours into the Colour struct.
* Allow current user to nickname themselvesAustin Hellyer2016-11-141-0/+35
| | | | | | | | | | | | | | | | | | Add support for the `PATCH /guilds/:guild_id/members/@me/nick` endpoint, which allows the current user to edit their own nickname. A user can only nickname themselves if they have the `Change Nickname` permission. This adds 4 methods: - `serenity::client::http::edit_nickname`; - `serenity::client::Context::edit_nickname`; - `serenity::model::Guild::edit_nickname`; - `serenity::model::LiveGuild::edit_nickname`. `LiveGuild`'s implementation checks for whether the current user has permission to change their own nickname.
* Add missing permission shorthandsAustin Hellyer2016-11-141-0/+16
|
* Add voice connection supportAustin Hellyer2016-11-143-61/+103
|
* Add internal moduleAustin Hellyer2016-11-1411-11/+11
| | | | | Create a general `internal` module, and move `prelude_internal` to `internal::prelude`.
* Move the builders to the utilsAustin Hellyer2016-11-133-3/+3
| | | | | | | | | The builders aren't a large enough portion of the library to deserve their own root-level module, so move them to the `utils` module. Additionally, split them into separate files, as the library will be receiving more builders and the single-file pattern was getting rather large.
* Don't overflow on message length checkAustin Hellyer2016-11-121-3/+3
|
* Add a check for message content lengthAustin Hellyer2016-11-121-6/+83
| | | | | | | | | | Before sending a request to Discord, ensure that a message's content on non-HTTP functions and methods meets the required length. If it exceeds the limit, then return a `Error::Client(ClientError::MessageTooLong(u64))`, containing the number of unicode code points exceeding the limit. Note that directly using the HTTP methods does not impose this limit.
* Add delete_message_reactions + register eventAustin Hellyer2016-11-112-2/+43
| | | | | | | | | Add the `delete_message_reactions` endpoint (`DELETE /channels/{}/messages/{}/reactions`) and implement a method on the `Message` struct for easy access, `delete_reactions`. Register the `MESSAGE_REACTION_REMOVE_ALL` event and add an event handler.
* Fix some clippy lintsAustin Hellyer2016-11-103-14/+2
|
* Add a Feature enumAustin Hellyer2016-11-091-1/+1
| | | | | | | | | | | | | | Features are handed by Discord to guilds that meet requirements which are most likely realistically arbitrary. The 3 features at this moment are: - INVITE_SPLASH - VANITY_URL - VIP_REGIONS On decoding of the two guild structs, map these string values to enum variants.
* Map op codes via a macroAustin Hellyer2016-11-091-2/+2
|
* Add Manage Webhooks to permissions 2FA listAustin Hellyer2016-11-081-0/+2
|
* Add webhook supportAustin Hellyer2016-11-076-1/+259
|
* Add Attachment::download{,to_directory}Austin Hellyer2016-11-071-0/+144
| | | | | | | | | | | | | | | Adds two methods to the Attachment model: - download: uses Hyper to download the attachment and return it as a vec of bytes; - download_to_directory: equivilant to `download`, except it will also save the bytes to a file named equivilant to the filename in a given directory. Check the documentation for Attachment for more information and examples: <https://docs.austinhellyer.me/serenity.rs/latest/serenity/model/struct.Attachment.html>
* Add some more documentationAustin Hellyer2016-11-063-7/+8
|
* Add a prelude for userlandAustin Hellyer2016-11-0510-10/+10
| | | | | | | Users can now import all of a prelude via `use serenity::prelude::*;`, which should provide some helpful stuff. As such, the internal prelude is now named `serenity::prelude_internal`, and all internal uses have been adjusted.
* Convert all doc anchors to named anchorsAustin Hellyer2016-11-051-6/+13
| | | | | | | | | | | | | | | | | | | | Convert all of the non-named anchors in docs to named anchors. Example: ```md Kicks a [`Member`](../model/struct.Member.html) from the specified [`Guild`](../model/struct.Guild.html) if they are in it. ``` is now written as: ```md Kicks a [`Member`] from the specified [`Guild`] if they are in it. [`Guild`]: ../model/struct.Guild.html [`Member`]: ../model/struct.Member.html ```
* Fix doc links to enum variantsAustin Hellyer2016-11-054-24/+24
| | | | | | Most of the docs were linking to `enum.EnumName.html#VariantName.v`, which should have been linking to `enum.EnumName.html#variant.VariantName`.
* Finalize invite-related documentationAustin Hellyer2016-11-051-16/+41
|
* Add message reactionsAustin Hellyer2016-11-055-9/+254
| | | | | | | | | | | | | | | | | | | | | | Add message reaction structs and an enum to differentiate between the two types of reactions, as well as event decoding and event handlers with dispatches. The following is, more or less, what is added: - `reactions` field to the `Message` struct; - `MessageReaction` struct, which is a consolidated form of reaction, containing the type of reaction, the number of them, and whether the current user has performed that type of reaction; - `Reaction`, a struct containing the information about a reaction - `ReactionType`, an enum to differentiate between the two types of reactions: `Custom` (a guild's custom emoji) and `Unicode` (twemoji); - Decoding for `MESSAGE_REACTION_ADD` and `MESSAGE_REACTION_REMOVE`; - Permission flag `ADD_REACTIONS`; - `Message::react` method; - Three `http` payload senders: `create_reaction`, `delete_reaction`, and `get_reaction_users`; - Three `Context` methods of equal names to the above.
* Abstract opcodes to enumsAustin Hellyer2016-10-221-12/+21
|