aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild
Commit message (Collapse)AuthorAgeFilesLines
...
* Deprecate `GuildId::as_channel_id` and add simulation methods for the ↵acdenisSK2017-08-042-1/+43
| | | | | | "default channel" concept Also fix a little mistake
* Change to c-like enums and transmuteacdenisSK2017-08-021-164/+55
|
* Use ranges instead of guardsacdenisSK2017-08-011-9/+7
|
* Clippy and rustfmtacdenisSK2017-08-012-8/+10
|
* Provide the input and limit back to the user, and do some consistenciesacdenisSK2017-08-012-3/+8
|
* Remove the `ext` module and remove a matchacdenisSK2017-08-011-6/+2
| | | | | The `ext` has existed for a long while just for backwards compatibility. But then again, majority of people should have migrated to the current modules already; making this module useless to keep in the library.
* Reuse `num`acdenisSK2017-07-311-8/+8
|
* Improve `Action`acdenisSK2017-07-311-100/+200
|
* Change the config a bit, and a few nitpicksacdenisSK2017-07-275-165/+150
|
* rustfmtacdenisSK2017-07-279-518/+430
|
* match -> and_thenacdenisSK2017-07-211-4/+1
|
* Utilise the newly stabilised loop-with-break-valueacdenisSK2017-07-201-13/+7
|
* Add an actual way to fetch audit log entries from a guildacdenisSK2017-07-203-0/+246
|
* Improve `BanOptions` to be more efficient and remove uneccessary `Read` importsacdenisSK2017-07-131-9/+9
|
* Remove the deprecated functionsacdenisSK2017-07-115-299/+0
| | | | It's already been enough time for people to migrate
* Rename `online_members` to `members_with_status` and compare the status ↵acdenisSK2017-07-101-3/+3
| | | | provided to the function instead
* Return an error if the reason the user provided exceeded the limitacdenisSK2017-07-102-2/+14
|
* Use a trait way of overloading the `ban` function instead of an enumacdenisSK2017-07-102-52/+37
| | | | Possibly removes some overhead introduced by enums but makes the underlaying code of the function easier to read and is more concise
* Fixed clippy warnings (#120)Kaidan2017-07-101-3/+3
|
* Make `User` and `Ban` comparable and hashableacdenisSK2017-07-101-1/+1
|
* Add a way to return all online members in a guildacdenisSK2017-07-091-0/+18
|
* Remove the note from the comment on `reason`acdenisSK2017-07-081-3/+0
| | | | Audit log works and does give a reason, so this note is just false info
* Implement attaching reasons to bansacdenisSK2017-07-082-7/+67
|
* Fixed clippy warnings (#118)Kaidan2017-06-281-1/+1
|
* Docs fixesmei2017-06-273-5/+2
|
* Add `Member::permissions`alex2017-06-141-0/+27
|
* Make Member::guild_id non-optionalZeyla Hellyer2017-06-132-63/+23
| | | | All codepaths result in Some value, so it doesn't need to be optional.
* Use chrono for struct timestamp fieldsZeyla Hellyer2017-06-062-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Chrono is easier to use than timestamped strings, so they should be automatically deserialized and available for the user, instead of having the user deserialize the strings themselves. These fields have been changed to use a type of `DateTime<FixedOffset>`: - `ChannelPinsUpdateEvent.last_pin_timestamp` - `Group.last_pin_timestamp` - `Guild.joined_at` - `GuildChannel.last_pin_timestamp` - `Invite.created_at` - `Member.joined_at` - `Message.edited_timestamp - `Message.timestamp` - `MessageUpdateEvent.edited_timestamp` - `MessageUpdateEvent.timestamp` - `PrivateChannel.last_pin_timestamp` `Member.joined_at` is now also an `Option`. Previously, if a Guild Member Update was received for a member not in the cache, a new Member would be instantiated with a default String value. This is incorrect behaviour, and has now been replaced with being set to `None` in that case. Id methods' `created_at()` method now return a `chrono::NaiveDateTime` instead of a `time::Timespec`, and `User::created_at` has been updated to reflect that. Additionally, drop `time` as a direct dependency and use chrono for internals.
* Add some model docs, deprecate Role::edit_roleMaiddog2017-06-032-4/+97
| | | Deprecate `Role::edit_role` and rename it to `Role::edit`.
* Fix compilations across feature combinationsZeyla Hellyer2017-06-025-17/+22
|
* 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.
* 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."
* Restructure modulesZeyla Hellyer2017-05-226-142/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-221-1/+1
|
* Don't skip everyone role when checking channel overwritesMaiddog2017-05-131-1/+1
|
* 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-043-0/+42
| | | | | 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.
* Make `User.discriminator` a u16Zeyla Hellyer2017-04-251-4/+5
| | | | | | | | | 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.
* Update most dependency version requirementsZeyla Hellyer2017-04-231-2/+2
| | | | | | | | 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.
* 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-193-269/+543
| | | | | | 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-123-0/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-118-126/+528
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-056-195/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-257-0/+2597