aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild/partial_guild.rs
Commit message (Collapse)AuthorAgeFilesLines
* Use `to_`- and `as_`-methods instead of `get` and `find` on Id newtypesLakelezz2018-08-121-3/+3
|
* Fix all the dead links in the docsErk-2018-08-091-32/+32
|
* Add 'Get Guild Vanity Url' endpointZeyla Hellyer2018-02-091-0/+10
| | | | Docs: <https://github.com/discordapp/discord-api-docs/commit/98f6643703012d2f3780ba730ce1191120f85dcd>
* Allow channels to be moved in and out of a category (#248)Kyle Clemens2018-01-081-3/+4
|
* Implement or derive Serialize on all modelsZeyla Hellyer2018-01-011-1/+1
|
* Fix most clippy lints, take more refeerncesZeyla Hellyer2017-12-161-1/+1
| | | | | Fix clippy lints and subsequently accept references for more function parameters.
* Break up the model moduleZeyla Hellyer2017-12-161-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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}; ```
* Change type of a couple Guild/PartialGuild fieldsZeyla Hellyer2017-12-151-2/+2
| | | | | | Changes the types of `Guild` and `PartialGuild`'s `default_message_notifications` and `mfa_level` structfields to be a bit more type-strong.
* Re-order use statements alphabeticallyZeyla Hellyer2017-11-111-1/+1
|
* 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.
* Remove `on_` prefix to EventHandler tymethodsZeyla Hellyer2017-10-221-1/+1
| | | | | It was voted that the `on_` prefix is unnecessary, so these have been dropped.
* Change `features` fields to be a Vec<String>Zeyla Hellyer2017-10-141-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When Discord adds new features, the Feature enum will not be able to serialize the new values until updated, causing the entire Guild deserialization to fail. Due to the fact that these features can be added at any time, the `features` vector on Guild and PartialGuild have been changed to be a `Vec<String>`. Upgrade path: Instead of matching on variants of Feature like so: ```rust use serenity::model::Feature; for feature in guild.features { if feature == Feature::VipRegions { // do work with this info } } ``` Instead opt to check the string name of the feature: ```rust for feature in guild.features { if feature == "VIP_REGIONS" { // do work with this info } } ```
* Apply rustfmtZeyla Hellyer2017-09-181-10/+8
|
* Remove more non-bot user endpointsZeyla Hellyer2017-09-011-16/+0
| | | | | | | | | | | | These include the following functions removed: - `http::get_application_info` - `http::get_applications` - `http::get_emoji` - `http::get_emojis` - `model::Guild::{emoji, emojis}` - `model::GuildId::{emoji, emojis}` - `model::PartialGuild::{emoji, emojis}`
* Make role references attainable via nameLakelezz2017-08-291-0/+34
|
* Add ability to play DCA and Opus files. (#148)Maiddog2017-08-271-11/+13
|
* Revamp `RwLock` usage in the libacdenisSK2017-08-241-13/+11
| | | | Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
* Apply rustfmtZeyla Hellyer2017-08-181-6/+6
|
* Change the config a bit, and a few nitpicksacdenisSK2017-07-271-13/+8
|
* rustfmtacdenisSK2017-07-271-67/+45
|
* Remove the deprecated functionsacdenisSK2017-07-111-91/+0
| | | | It's already been enough time for people to migrate
* Docs fixesmei2017-06-271-1/+0
|
* Restructure modulesZeyla Hellyer2017-05-221-13/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix guild leaving resultZeyla Hellyer2017-05-051-1/+1
| | | | | | | | | | | | | | | | 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 a test suite for event deserializationZeyla Hellyer2017-04-191-0/+3
| | | | | | | | | | | | 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.
* Deprecate methods prefixed with `get_`Zeyla Hellyer2017-04-191-77/+168
| | | | | | 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.
* Add Shard Id helpersZeyla Hellyer2017-04-121-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Switch to using serde for deserializationZeyla Hellyer2017-04-111-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-74/+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/+482