aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Add faded_purple to colour listMei2017-05-131-1/+3
| | | Add `faded_purple` as a Colour, and rename `meibi_pink` to `meibe_pink`.
* Framework: trim content before parsing argsMaiddog2017-05-121-7/+11
|
* Add Eq, PartialEq, Hash to ReactionType derivesalex2017-05-121-1/+1
|
* Check if message starts with dynamic_prefix resultMaiddog2017-05-081-1/+3
|
* 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-054-10/+5
| | | | | | | | | | | | | | | | 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.
* Add framework dynamic_prefix exampleZeyla Hellyer2017-05-041-2/+24
|
* 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-022-19/+43
| | | | | | | | 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-265-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-254-23/+12
| | | | | | | | | 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-239-60/+61
| | | | | | | | 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.
* Fix ratelimiting on `Route::None` routesZeyla Hellyer2017-04-191-0/+2
| | | | | | | Routes with a `Route::None` - to indicate not to keep a ratelimit bucket - would enter a loop on the route. To fix this, add an `else` block to the check for whether the route is _not_ `Route::None`, and return from it.
* Clippy lintsZeyla Hellyer2017-04-191-15/+13
|
* Accept a slice of args in help commandsZeyla Hellyer2017-04-194-5/+5
| | | | | The help commands don't actually need to have the arguments passed by value, so passing them by reference is fine.
* Remove ChannelPinsAck/MessageAck eventsZeyla Hellyer2017-04-194-43/+0
| | | | | These events are mostly only userbot events and were leftover from userbot support.
* Fix an unused use on non-cacheZeyla Hellyer2017-04-191-1/+2
| | | | | A use statement in shard.rs was only necessary on cached compiles. To fix this, gate it behind the `cache` feature.
* Check for embed lengths on message sendsZeyla Hellyer2017-04-195-12/+75
| | | | | | | | | | | | | | | | | | | | | | 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.
* Implement `From<&str> for ReactionType`Zeyla Hellyer2017-04-191-0/+22
| | | | | | | | | | | | | | | | Implement the ability to create a ReactionType from a string slice. This is to be able to produce code like: ```rust msg.react("🍎"); ``` rather than needing to go the longer route: ```rust msg.react("🍎".to_owned()); ```
* Deprecate methods prefixed with `get_`Zeyla Hellyer2017-04-1916-460/+1043
| | | | | | A lot of structs - such as `Guild` or `ChannelId` - have methods with prefixes of `get_`, which are generally discouraged. To fix this, deprecate them and remove them in v0.3.0.
* Update the way errors are handled in dispatchIllia2017-04-194-403/+179
|
* Default to using [0, 1] shardsZeyla Hellyer2017-04-131-1/+1
| | | | | | | | | | | | | When using an unsharded client, the shard data sent in the IDENTIFY should default to `[0, 1]`, as sending a null value results in a 4010 response code. The response code for the error looks like: ``` WARN:serenity::client: Failed to boot shard: Gateway(Closed(Some(4010), "Invalid shard.")) WARN:serenity::client: Error starting shard None: Client(ShardBootFailure) ```
* Add Shard Id helpersZeyla Hellyer2017-04-127-1/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add helpers to retrieve the shard Id for guilds, and count how many guilds are handled by a Shard. Helpers to retrieve the shard Id of a guild have been added as: - `Guild::shard_id` - `GuildId::shard_id` These are in two forms: one working with the cache feature, and one without. The function that works with the cache will automatically retrieve the total number of shards from the Cache, while the uncached version requires passing in the total number of shards used. With the cache enabled, this might look like: ```rust guild.shard_id(); // which calls: guild_id.shard_id(); ``` Without the cache enabled, this looks like: ```rust let shard_count = 7; guild.shard_id(shard_count); // which calls: guild_id.shard_id(shard_count); ``` These two variants on `Guild` and `GuildId` are helper sugar methods over the new function `utils::shard_id`, which accepts a `guild_id` and a `shard_count`: ```rust use serenity::utils; assert_eq!(utils::shard_id(81384788765712384, 17), 7); ``` You would use `utils::shard_id` when you have the total number of shards due to `{Guild,GuildId}::shard_id` unlocking the cache to retrieve the total number of shards. This avoids some amount of work
* Fix `client::rest::delete_webhook_with_token` testZeyla Hellyer2017-04-111-0/+1
| | | | | | | | The doctest for this function did not have an ending code fence, causing the remaining documentation to be lexed as part of the doctest. To fix this, add a code fence after the code and prior to the named anchor links.
* Switch to using serde for deserializationZeyla Hellyer2017-04-1151-1552/+2844
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current build system is rudimentary, incomplete, and rigid, offering little in the way of customizing decoding options. To solve this, switch to using serde-derive with custom Deserialization implementations. This allows very simple deserialization when special logic does not need to be applied, yet allows us to implement our own deserialization logic when required. The problem with the build system was that it built enums and structs from YAML files. This is not so good, because it requires creating a custom build system (which was rudimentary), creating "special struct configs" when logic needed to be ever so slightly extended (rigid), and if special logic needed to be applied, a custom deserialization method would have been needed to be made anyway (incomplete). To solve this, switch to serde-derive and implementing Deserialize ourselves where required. This reduces YAML definitions that might look like: ```yaml --- name: Group description: > A group channel, potentially including other users, separate from a [`Guild`]. [`Guild`]: struct.Guild.html fields: - name: channel_id description: The Id of the group channel. from: id type: ChannelId - name: icon description: The optional icon of the group channel. optional: true type: string - name: last_message_id description: The Id of the last message sent. optional: true type: MessageId - name: last_pin_timestamp description: Timestamp of the latest pinned message. optional: true type: string - name: name description: The name of the group channel. optional: true type: string - name: owner_id description: The Id of the group channel creator. type: UserId - name: recipients description: Group channel's members. custom: decode_users t: UserId, Arc<RwLock<User>> type: hashmap ``` to: ```rs /// A group channel - potentially including other [`User`]s - separate from a /// [`Guild`]. /// /// [`Guild`]: struct.Guild.html /// [`User`]: struct.User.html pub struct Group { /// The Id of the group channel. #[serde(rename="id")] pub channel_id: ChannelId, /// The optional icon of the group channel. pub icon: Option<String>, /// The Id of the last message sent. pub last_message_id: Option<MessageId>, /// Timestamp of the latest pinned message. pub last_pin_timestamp: Option<String>, /// The name of the group channel. pub name: Option<String>, /// The Id of the group owner. pub owner_id: UserId, /// A map of the group's recipients. #[serde(deserialize_with="deserialize_users")] pub recipients: HashMap<UserId, Arc<RwLock<User>>>, } ``` This is much simpler and does not have as much boilerplate. There should not be any backwards incompatible changes other than the old, public - yet undocumented (and hidden from documentation) - decode methods being removed. Due to the nature of this commit, field names may be incorrect, and will need to be corrected as deserialization errors are found.
* Clippy lints + permission byte literalsZeyla Hellyer2017-04-096-41/+40
| | | | | Perform a number of various clippy lints, and rewrite the permissions values to use byte literals instead of bitshifts.
* Remove support for group calls and guild syncZeyla Hellyer2017-04-0913-553/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calls and guild sync are essentially leftovers from selfbot support removal, the former moreso. Removes the following `model::event` structs: - CallCreateEvent - CallDeleteEvent - CallUpdateEvent - GuildSyncEvent which also removes the following `model::event::Event` variants: `client::gateway::Shard::sync_calls` has been removed. The following `client::Client` methods have been removed: - `on_call_create` - `on_call_delete` - `on_call_update` - `on_guild_sync` Removes the following items on `ext::cache::Cache`: ``` ext::cache::Cache::{ // fields calls, // methods get_call, update_with_call_create, update_with_call_delete, update_with_call_update, update_with_guild_sync, } ``` Voice structs and methods now take solely a `guild_id` instead of a `target`, due to the handling of 1-on-1 and group calls being removed. This continues off commit d9118c0.<Paste>
* Remove selfbot supportZeyla Hellyer2017-04-0535-1838/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While selfbots have always been "roughly tolerated", lately they have been tolerated to less of a degree. The simple answer is to no longer support selfbots in any form. This is done for a few of reasons: 1) in anticipation of selfbots no longer being tolerated; 2) there are few reasons why one should make a selfbot in Rust and not a scripting language; 3) there are alternatives (i.e. discord-rs) that still support userbots. Selfbots are simply not a goal of the maintainer of serenity. Upgrade path: Don't use selfbots with serenity. Use discord-rs instead. The following has been removed: Enums: - `RelationshipType` Structs: - `FriendSourceFlags` - `ReadState` - `Relationship` - `SearchResult` - `SuggestionReason` - `Tutorial` - `UserConnection` - `UserGuildSettings` - `UserSettings` Removed the following fields: - `CurrentUser::mobile` - Ready::{ analytics_token, experiments, friend_suggestion_count, notes, read_state, relationships, tutorial, user_guild_settings, user_settings, } Removed the following methods: - `Client::login_user` Deprecated `Client::login_bot` in favour of `Client::login`. Removed `client::LoginType`. The following no longer take a `login_type` parameter: - `Context::new` - `Shard::new` `Shard::sync_guilds` has been removed. The `client::Error::{InvalidOperationAsBot, InvalidOperationAsUser}` variants have been removed. The following event handlers on `Client` have been removed: - `on_friend_suggestion_create` - `on_friend_suggestion_delete` - `on_relationship_add` - `on_relationship_remove` - `on_user_guild_settings_update` - `on_note_update` - `on_user_settings_update` The following `client::rest` functions have been removed: - `ack_message` - `edit_note` - `get_user_connections` - `search_channel_messages` - `search_guild_messages` The following `client::rest::ratelimiting::Route` variants have been removed: - `ChannelsIdMessagesSearch` - `GuildsIdMessagesSearch` - `UsersMeConnections` The following fields on `ext::cache::Cache` have been removed: - `guild_settings` - `relationships` - `settings` while the following methods have also been removed: - `update_with_relationship_add` - `update_with_relationship_remove` - `update_with_user_guild_settings_update` - `update_with_user_note_update` - `update_with_user_settings_update` The following methods have been removed across models: - `ChannelId::{ack, search}` - `Channel::{ack, search}` - `Group::{ack, search}` - `GuildChannel::{ack, search}` - `GuildId::{search, search_channels}` - `Guild::{search, search_channels}` - `Message::ack` - `PartialGuild::{search, search_channels}` - `PrivateChannel::{ack, search}` - `UserId::{delete_note, edit_note}` - `User::{delete_note, edit_note}` The following events in `model::events` have been removed: - `FriendSuggestionCreateEvent` - `FriendSuggestionDeleteEvent` - `MessageAckEvent` - `RelationshipAddEvent` - `RelationshipRemoveEvent` - `UserGuildSettingsUpdateEvent` - `UserNoteUpdateEvent` - `UserSettingsUpdateEvent` Consequently, the following variants on `model::event::Event` have been removed: - `FriendSuggestionCreate` - `FriendSuggestionDelete` - `MessageAdd` - `RelationshipAdd` - `RelationshipRemove` - `UserGuildSettingUpdate` - `UserNoteUpdate` - `UserSettingsUpdate` The `utils::builder::Search` search builder has been removed.
* Improve some framework docsZeyla Hellyer2017-03-251-5/+16
|
* Fix testsZeyla Hellyer2017-03-252-2/+2
|
* Update search paramsZeyla Hellyer2017-03-253-211/+139
|
* Rework the models directoryZeyla Hellyer2017-03-2519-5311/+5353
|
* Add slightly more documentationZeyla Hellyer2017-03-2510-8/+412
|
* Fix Member methods due to variant joined_at valuesZeyla Hellyer2017-03-205-23/+49
| | | | | | | | | | | | | | | Fix an issue where the library would check the Id of the guild that a member is in by checking the Member's ID and joined_at value with those of the members of guilds present in the cache. Performing this check would have the issue of where a joined_at for a member received over websocket would potentially have a varying value than that of the same member retrieved over REST. To fix this, attach the relevant guild's Id to the member on creation, where the Id is available. Fixes #68.
* Fix deadlock/panic on channel create event for private messagesSteffen Schröter2017-03-191-1/+1
|
* Fix rest::send_fileZeyla Hellyer2017-03-171-1/+8
| | | | | | Remove usage of `Value::to_string` - which would encapsulate the produced value with quotation marks - and instead match the type of value and wwrite the text accordingly.
* Fix no-cache compilationsZeyla Hellyer2017-03-171-1/+1
|
* Fix incorrect cache exampleSteffen Schröter2017-03-171-1/+1
|
* Remove invite acceptingZeyla Hellyer2017-03-042-108/+0
|
* Fix client::rest::get_guilds doctestZeyla Hellyer2017-03-031-1/+1
| | | | | The doctest did not pass by reference per an update caused by 28743c8632458b79b472e3719d4754b57e116ad0.
* aZeyla Hellyer2017-03-011-4/+1
|
* Add Message::guild()Zeyla Hellyer2017-03-011-0/+16
|
* Fix some clippy lintsZeyla Hellyer2017-02-282-4/+3
|