aboutsummaryrefslogtreecommitdiff
path: root/src/model
Commit message (Collapse)AuthorAgeFilesLines
...
* Add CurrentUser::default_avatar_urlZeyla Hellyer2017-06-041-0/+7
| | | | | Add `default_avatar_url` to `CurrentUser` to match `User`'s avatar functions.
* Add Message::channel()Zeyla Hellyer2017-06-041-0/+43
| | | | | The method can be used as a shortcut for retrieving a message's channel from the cache.
* Add some model docs, deprecate Role::edit_roleMaiddog2017-06-034-4/+148
| | | Deprecate `Role::edit_role` and rename it to `Role::edit`.
* Fix compilations across feature combinationsZeyla Hellyer2017-06-0218-57/+84
|
* Add User::refreshZeyla Hellyer2017-06-021-0/+58
|
* Fix no-feature compilationsZeyla Hellyer2017-06-011-0/+1
| | | | | | An internal `tag` function created in a previous commit is only required for use when the `"model"` feature is enabled, but the function itself was not gated behind the feature.
* Deprecate User::getZeyla Hellyer2017-06-011-0/+1
| | | | | | The function no longer fit's a short-lived period of serenity's design, where it would have been preferred to do `User::get(ID)` over `UserId(ID).get()`.
* Deprecate *User::distinct, add *User::tagZeyla Hellyer2017-06-011-16/+73
| | | | | | | | | | `distinct`, although accurate, is an odd name for the method. Deprecate `distinct` on `CurrentUser` and `User` and rename them to `tag`. Additionally, optimize the creation of the resultant String by about 2x. Instead of using the `format!` macro, create a new String with a capacity of 37 and push the username, `'#'`, and write the discriminator in manually.
* Add docs for CurrentUserMaiddog2017-05-301-0/+103
|
* Implement multiple attachmentsKen Swenson2017-05-285-0/+192
|
* impl From<char> for ReactionTypeZeyla Hellyer2017-05-281-0/+27
| | | | This can be used as a helpful shortcut for reactions.
* Add CurrentUser::invite_url methodMaiddog2017-05-271-0/+12
|
* Guild::create_channel doesn't require mutabilityZeyla Hellyer2017-05-271-1/+1
| | | | | Change `Guild::create_channel` to take a non-mutable reference, as mutability isn't required.
* Remove deprecated GuildChannel methodsZeyla Hellyer2017-05-271-51/+0
| | | | | | | | | | | | | Remove the deprecated GuildChannel methods in preparation of an incoming commit modifying GuildChannel. Remove the following deprecated methods: - `get_invites` - `get_message` - `get_messages` - `get_reaction_users` - `get_webhooks`
* Fix incorrect attempted send_file deserializationZeyla Hellyer2017-05-275-0/+26
| | | | | | | | | | | If http::send_file received a non-success status code due to reasons such as sending to an invalid channel Id, not having permissions, or sending too large of a file, then it would still try to deserialize a response as if it were valid. To fix this, ensure that the response is successful. Document that if the file sent is too large, then `HttpError::InvalidRequest(PayloadTooLarge)` is returned.
* Fix GuildChannel::create_permission anchor linkZeyla Hellyer2017-05-271-0/+1
| | | | A link to model::permissions::SEND_MESSAGES was broken.
* Fix GuildChannel::create_permission examplesZeyla Hellyer2017-05-271-14/+46
| | | | | | The examples didn't bring `model::PermissionOverwriteType` into scope. Additionally, wrap the examples in try_main's to make use of the `?` operator.
* Change create_permission to take a referenceZeyla Hellyer2017-05-272-4/+4
| | | | | {ChannelId,GuildChannel}::create_permission don't need to take ownership over the overwrite, so just accept a reference.
* Add VerificationLevel::HigherZeyla Hellyer2017-05-261-3/+6
| | | | | A new verification level was added for guilds with a value of 4, which means "Must have a verified phone on their Discord account."
* Move Reaction struct into its proper placeZeyla Hellyer2017-05-242-20/+20
| | | | | The struct was previously in `src/model/channel/message.rs` instead of its own `src/model/channel/reaction.rs` file.
* Clippy lintsZeyla Hellyer2017-05-241-2/+1
|
* Support adding reactions when creating messagealex2017-05-241-2/+10
| | | | These reactions are added onto the `MessageCreate` builder, and are sent after the message has been created.
* Add more examples and improve some othersZeyla Hellyer2017-05-231-1/+1
| | | | | Add examples to some functions, and update some of the old examples to use the `?` operator instead of unwrapping.
* Fix {Invite,RichInvite}::url testsZeyla Hellyer2017-05-221-0/+6
| | | | | Add fields in struct instantiation for the new stats fields introduced by the recent invite stats commit.
* Restructure modulesZeyla Hellyer2017-05-2225-390/+597
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modules are now separated into a fashion where the library can be used for most use cases, without needing to compile the rest. The core of serenity, with no features enabled, contains only the struct (model) definitions, constants, and prelude. Models do not have most functions compiled in, as that is separated into the `model` feature. The `client` module has been split into 3 modules: `client`, `gateway`, and `http`. `http` contains functions to interact with the REST API. `gateway` contains the Shard to interact with the gateway, requiring `http` for retrieving the gateway URL. `client` requires both of the other features and acts as an abstracted interface over both the gateway and REST APIs, handling the event loop. The `builder` module has been separated from `utils`, and can now be optionally compiled in. It and the `http` feature are required by the `model` feature due to a large number of methods requiring access to them. `utils` now contains a number of utilities, such as the Colour struct, the `MessageBuilder`, and mention parsing functions. Each of the original `ext` modules are still featured, with `cache` not requiring any feature to be enabled, `framework` requiring the `client`, `model`, and `utils`, and `voice` requiring `gateway`. In total the features and their requirements are: - `builder`: none - `cache`: none - `client`: `gateway`, `http` - `framework`: `client`, `model`, `utils` - `gateway`: `http` - `http`: none - `model`: `builder`, `http` - `utils`: none - `voice`: `gateway` The default features are `builder`, `cache`, `client`, `framework`, `gateway`, `model`, `http`, and `utils`. To help with forwards compatibility, modules have been re-exported from their original locations.
* Reasonably derive Debug on itemsZeyla Hellyer2017-05-222-1/+2
|
* Remove more remaining selfbot supportZeyla Hellyer2017-05-225-214/+0
| | | | We removed these a long time ago, and these were missed.
* Add `Invite::url()`, `RichInvite::url()`Zeyla Hellyer2017-05-221-0/+72
| | | | | Add helper methods to easily produce invite URLs, such as `"https://discord.gg/WxZumR"`.
* Add GuildChannel::permissions_forZeyla Hellyer2017-05-221-0/+87
| | | | Add a method to calculate a member's permissions in the channel.
* Handle message type 7 (member join)illia k2017-05-222-0/+37
| | | | | | | | | | When message type 7 is received from the gateway, transform the content if the type is 7 to a proper greeting. Additionally, when the type is 6, provide a proper content notifying that a user has pinned a message to the channel. These transformations are not done at REST-level when retrieving messages, and are instead done in `ChannelId::message` and `ChannelId::messages`.
* Add support for retrieving invites with countsMei2017-05-181-4/+17
| | | | | | | Previously retrieving an invite with the `?with_counts=true` wasn't possible. Added support to `get_invite` for retrieving an invite with the counts, this requires the user to pass true to the function. The counts include `approximate_presence_count` and `approximate_member_count` which have been added to the `Invite` stuct, as well as `text_channel_count` and `voice_channel_count` to the `InviteGuild` struct.
* Don't skip everyone role when checking channel overwritesMaiddog2017-05-131-1/+1
|
* Fix unused import lintZeyla Hellyer2017-05-131-1/+2
|
* Add Eq, PartialEq, Hash to ReactionType derivesalex2017-05-121-1/+1
|
* Fix permissions when sending to DMs or groupsalex2017-05-071-3/+12
| | | | | | | When performing an action on a DM Channel or Group, an arbitrary permission check would always fail, causing the action to error out with a lacking permissions error. To fix this, just assume the action will always succeed.
* Fix guild leaving resultZeyla Hellyer2017-05-053-3/+3
| | | | | | | | | | | | | | | | When leaving a guild, `rest::leave_guild` would attempt to deserialize a JSON body containing a partial amount of guild info, resulting in an error: ``` Could not leave guild: Json(ErrorImpl { code: EofWhileParsingValue, line: 1, column: 0 }) ``` Although the bot would still actually leave the guild, it would always return this error. To fix this, don't try to deserialize anything and only check for a 204 instead.
* Accept references on Into<Id>Zeyla Hellyer2017-05-046-0/+94
| | | | | By accepting references, users don't have to either pass in the entirity of an instance or clone it.
* Add missing Member::kick shortcutZeyla Hellyer2017-05-021-1/+62
| | | | | | A shortcut for kicking a member directly was missing, so add it in. This method performs permission checking.
* Return preset from Member::find_guild if possibleZeyla Hellyer2017-05-021-0/+9
| | | | | | | If a value is present for `Member::guild_id` when calling `Member::find_guild`, return that value instead of searching the cache. This can potentially save a large amount of calculations and time.
* Use constant for preset permissionsZeyla Hellyer2017-05-021-17/+41
| | | | | | | | Instead of having methods which return a preset value, use constants since the actual values are themselves constant. Deprecate the previous methods and move documentation to the new constants.
* Fix non-custom emoji deserializationZeyla Hellyer2017-04-271-3/+86
| | | | | | | | | Deserializing a non-custom emoji would fail, as an Id would always be expected. To fix this, special-case that if a name and id are both present, to deserialize it as a Custom emoji reaction. Otherwise, use only the name and deserialize as a basic reaction.
* Add `is_nsfw` check to channelsZeyla Hellyer2017-04-264-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new feature in Discord is warning users about NSFW channels. This can be useful when wanting to determine if a command can be used in a channel or not, depending on the command content. To help with this, provide a utility function named `utils::is_nsfw`. This function accepts a channel name, which determines if the channel is NSFW. This information is not provided with data from the server. It is determined client-side based on a few rules. The rules for a channel being NSFW are: - must be a guild channel - must be a text channel - must be named `nsfw` or be prefixed with `nsfw-` If any of these conditions are false, then the channel is not NSFW. Additionally, provide four helper methods: - `GuildChannel::is_nsfw`: follows rules - `Group::is_nsfw`: always false - `PrivateChannel::is_nsfw`: always false - `Channel::is_nsfw`: depends on inner channel (one of 3 above) This check is volatile, as Discord may change requirements at any time. The check provided by the library should not be taken as being accurate all the time.
* Make `User.discriminator` a u16Zeyla Hellyer2017-04-253-20/+11
| | | | | | | | | Change the User struct's `discriminator` field to a u16 for performance. The User struct's `discriminator` field was previously a u16 but changed to a `String` for ease-of-use. Lately the library has been gearing more towards performance where possible while not sacrificing ergonomics _too much_ in most scenarios.
* Fix decoding for `CurrentUser.discriminator`Zeyla Hellyer2017-04-252-0/+39
| | | | | | Due to the serde 1.0 upgrade, integers are no longer automatically deserialized from Strings. To resolve this, create a visitor that performs the operation based on the input.
* Fix embed length checkzeyla2017-04-251-2/+2
|
* Fix deserialization for IdsZeyla Hellyer2017-04-243-1/+50
| | | | | Attempt to deserialize from both a str and a u64 instead of the default derive impl.
* Update most dependency version requirementsZeyla Hellyer2017-04-237-55/+55
| | | | | | | | Update the dependencies `base64`, `bitflags`, `byteorder`, `serde`, `serde_derive`, and `serde_json`. These dependencies have been updated, with byteorder and serde** hitting v1.0.0, so they should be updated for the v0.2.0 serenity release.
* Remove ChannelPinsAck/MessageAck eventsZeyla Hellyer2017-04-191-14/+0
| | | | | These events are mostly only userbot events and were leftover from userbot support.
* Check for embed lengths on message sendsZeyla Hellyer2017-04-192-7/+67
| | | | | | | | | | | | | | | | | | | | | | Due to the maximum length of the textual content of an embed being 4000, this should be checked prior to message sending. Embeds have a fairly new limit of only being 4000 character long, at maximum. The length of these fields - where present - should be summed, so that bad requests are not made with embeds that are too large in text. The fields that count as "textual" includes: - author name - description - `name` and `value` of each field - footer text - title If this exceeds the limit - currently at 4000 unicode codepoints - then a `ClientError::EmbedTooLarge` will be returned, including the number of codepoints overflowing.
* Add a test suite for event deserializationZeyla Hellyer2017-04-192-0/+5
| | | | | | | | | | | | Add a test suite for most of the events that can be easily procuced, and store them in static JSON files so the tests are ran on every build. The recent update to using serde{,_derive} for deserialization was a rough patch, as it was a large change which couldn't be fully tested at the time. By adding JSON files which are deserialized, this will produce a test suite that can be easily run on every new set of commits to prevent any backwards incompatible changes with regards to deserialization.