aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel/mod.rs
Commit message (Collapse)AuthorAgeFilesLines
* Fix NSFW Checks (#418)Lakelezz2018-10-201-7/+3
|
* Use `to_`- and `as_`-methods instead of `get` and `find` on Id newtypesLakelezz2018-08-121-4/+26
|
* Fix all the dead links in the docsErk-2018-08-091-24/+24
|
* Fix compilation + tests on certain feature combosZeyla Hellyer2018-08-071-5/+37
| | | | | | | | On certain feature combinations, compilation and tests would not function correctly. This commit goes through a number of feature combinations and gates some tests behind the required features and fixes other compilation errors.
* Fix some documentation spacingZeyla Hellyer2018-08-071-17/+11
|
* 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.
* Fix nsfw related docs (#299)Lakelezz2018-04-041-1/+1
|
* Change the way ids and some enums are made (#295)Leah2018-03-231-22/+31
| | | | | This makes them easier to be found by tools like rls. Also update struct inits to use the shorthand version for `x: x`.
* Add an `EditMessage` builderZeyla Hellyer2018-01-181-5/+5
| | | | | | 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-1/+40
|
* Add missing 'num' implementations on modelsZeyla Hellyer2017-12-271-0/+10
| | | | | | | Add missing 'num' implementations from the following models: - `channel::{ChannelType, MessageType}` - `gateway::GameType`
* Add variant adapters to Channel (#238)Timo2017-12-201-0/+133
|
* Break up the model moduleZeyla Hellyer2017-12-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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}; ```
* Re-order use statements alphabeticallyZeyla Hellyer2017-11-111-3/+3
|
* Merge v0.4.2acdenisSK2017-10-241-0/+11
|\
| * 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`
| * Fix most clippy warningsMaiddog2017-10-041-1/+1
| |
| * Replace Vec parameters by IntoIterator (#176)François Triquet2017-10-041-1/+1
| |
* | Switch to parking_lot::{Mutex, RwLock}Zeyla Hellyer2017-10-101-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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); ```
* | Fix most clippy warningsMaiddog2017-10-091-1/+1
| |
* | Replace Vec parameters by IntoIterator (#176)François Triquet2017-10-091-1/+1
|/
* Apply rustfmtZeyla Hellyer2017-09-181-35/+18
|
* Fix compiles of a variety of feature combinationsZeyla Hellyer2017-09-181-5/+15
| | | | | This fixes compilation errors and warnings when compiling a mixture of non-default feature targets.
* Implement categoriesacdenisSK2017-09-091-0/+22
|
* Add ability to play DCA and Opus files. (#148)Maiddog2017-08-271-17/+33
|
* Revamp `RwLock` usage in the libacdenisSK2017-08-241-37/+22
| | | | Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
* Apply rustfmtZeyla Hellyer2017-08-181-14/+28
|
* Change the config a bit, and a few nitpicksacdenisSK2017-07-271-39/+20
|
* rustfmtacdenisSK2017-07-271-45/+66
|
* Improve `BanOptions` to be more efficient and remove uneccessary `Read` importsacdenisSK2017-07-131-2/+0
|
* Remove the deprecated functionsacdenisSK2017-07-111-95/+0
| | | | It's already been enough time for people to migrate
* Docs fixesmei2017-06-271-1/+1
|
* Deprecate a couple Channel methodsZeyla Hellyer2017-06-171-0/+2
| | | | | | | Deprecate `Channel::delete_messages` and `Channel::delete_permission`. These methods aren't available on all of the variants' types, so they shouldn't be on the Channel either.
* Fix links to ChannelId::send_filesZeyla Hellyer2017-06-041-2/+2
| | | | | | Helper methods such as `GuildChannel::send_files` linked to the documentation for `ChannelId::send_file`, when they should be linking to `ChannelId::send_files`.
* Make http::AttachmentType only use borrowed valuesZeyla Hellyer2017-06-041-2/+2
| | | | | With the way AttachmentType is meant to be used by `http::send_files`, none of the values need to be moved, they only need to be borrowed.
* Fix compilations across feature combinationsZeyla Hellyer2017-06-021-2/+4
|
* Implement multiple attachmentsKen Swenson2017-05-281-0/+28
|
* Fix incorrect attempted send_file deserializationZeyla Hellyer2017-05-271-0/+5
| | | | | | | | | | | 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.
* Clippy lintsZeyla Hellyer2017-05-241-2/+1
|
* Restructure modulesZeyla Hellyer2017-05-221-15/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove more remaining selfbot supportZeyla Hellyer2017-05-221-18/+0
| | | | We removed these a long time ago, and these were missed.
* Add `is_nsfw` check to channelsZeyla Hellyer2017-04-261-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix deserialization for IdsZeyla Hellyer2017-04-241-0/+2
| | | | | Attempt to deserialize from both a str and a u64 instead of the default derive impl.
* Update most dependency version requirementsZeyla Hellyer2017-04-231-4/+4
| | | | | | | | 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.
* Deprecate methods prefixed with `get_`Zeyla Hellyer2017-04-191-10/+43
| | | | | | 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.
* Switch to using serde for deserializationZeyla Hellyer2017-04-111-27/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove selfbot supportZeyla Hellyer2017-04-051-56/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Rework the models directoryZeyla Hellyer2017-03-251-0/+415