diff options
| author | Zeyla Hellyer <[email protected]> | 2017-04-05 08:14:43 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-04-05 08:55:01 -0700 |
| commit | d9118c081742d6654dc0a4f60228a7a212ca436e (patch) | |
| tree | 003f49f54769314c1111e942d77f57513406fb5e /src/ext/cache/mod.rs | |
| parent | Add a sample bot structure example (diff) | |
| download | serenity-d9118c081742d6654dc0a4f60228a7a212ca436e.tar.xz serenity-d9118c081742d6654dc0a4f60228a7a212ca436e.zip | |
Remove selfbot support
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.
Diffstat (limited to 'src/ext/cache/mod.rs')
| -rw-r--r-- | src/ext/cache/mod.rs | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/src/ext/cache/mod.rs b/src/ext/cache/mod.rs index ad0ef31..7bb9dd8 100644 --- a/src/ext/cache/mod.rs +++ b/src/ext/cache/mod.rs @@ -49,19 +49,6 @@ //! while needing to hit the REST API as little as possible, then the answer //! is "yes". //! -//! # Special cases in the Cache -//! -//! Some items in the cache, notably [`Call`]s and [`Group`]s, will "always be -//! empty". The exception to this rule, is for: -//! -//! 1. Bots which used to be userbots prior to the conversion made available by -//! Discord when the official Bot API was introduced; -//! 2. For groups and calls: -//! 2a. Bots that have friends from before the conversion that have not been -//! removed, as those users can still add the bots to groups; -//! 2b. Bots that have the "Create Group" endpoint whitelisted specifically for -//! them. -//! //! [`Call`]: ../../model/struct.Call.html //! [`Context`]: ../../client/struct.Context.html //! [`Context::get_channel`]: ../../client/struct.Context.html#method.get_channel @@ -143,10 +130,6 @@ pub struct Cache { /// /// [special cases]: index.html#special-cases-in-the-cache pub groups: HashMap<ChannelId, Arc<RwLock<Group>>>, - /// Settings specific to a guild. - /// - /// This will always be empty for bot users. - pub guild_settings: HashMap<Option<GuildId>, UserGuildSettings>, /// A map of guilds with full data available. This includes data like /// [`Role`]s and [`Emoji`]s that are not available through the REST API. /// @@ -167,14 +150,6 @@ pub struct Cache { /// A map of direct message channels that the current user has open with /// other users. pub private_channels: HashMap<ChannelId, Arc<RwLock<PrivateChannel>>>, - /// A map of relationships that the current user has with other users. - /// - /// For bot users this will always be empty, except for in [special cases]. - /// - /// [special cases]: index.html#special-cases-in-the-cache - pub relationships: HashMap<UserId, Relationship>, - /// Account-specific settings for a user account. - pub settings: Option<UserSettings>, /// A list of guilds which are "unavailable". Refer to the documentation for /// [`Event::GuildUnavailable`] for more information on when this can occur. /// @@ -969,12 +944,6 @@ impl Cache { } } - if let Some(user_guild_settings) = ready.user_guild_settings { - for guild in user_guild_settings { - self.guild_settings.insert(guild.guild_id, guild); - } - } - for (user_id, presence) in &mut ready.presences { if let Some(ref user) = presence.user { self.update_user_entry(&user.read().unwrap()); @@ -984,69 +953,10 @@ impl Cache { } self.presences.extend(ready.presences); - self.relationships.extend(ready.relationships); - self.notes.extend(ready.notes); - self.settings = ready.user_settings; self.user = ready.user; } #[doc(hidden)] - pub fn update_with_relationship_add(&mut self, event: &RelationshipAddEvent) { - self.update_user_entry(&event.relationship.user); - - self.relationships.insert(event.relationship.id, event.relationship.clone()); - } - - #[doc(hidden)] - pub fn update_with_relationship_remove(&mut self, event: &RelationshipRemoveEvent) { - self.relationships.remove(&event.user_id); - } - - #[doc(hidden)] - pub fn update_with_user_guild_settings_update(&mut self, event: &UserGuildSettingsUpdateEvent) - -> Option<UserGuildSettings> { - self.guild_settings - .get_mut(&event.settings.guild_id) - .map(|guild_setting| mem::replace(guild_setting, event.settings.clone())) - } - - #[doc(hidden)] - pub fn update_with_user_note_update(&mut self, event: &UserNoteUpdateEvent) -> Option<String> { - if event.note.is_empty() { - self.notes.remove(&event.user_id) - } else { - self.notes.insert(event.user_id, event.note.clone()) - } - } - - #[doc(hidden)] - pub fn update_with_user_settings_update(&mut self, event: &UserSettingsUpdateEvent, old: bool) - -> Option<UserSettings> { - let item = if old { - self.settings.clone() - } else { - None - }; - - self.settings - .as_mut() - .map(|settings| { - opt_modify(&mut settings.enable_tts_command, &event.enable_tts_command); - opt_modify(&mut settings.inline_attachment_media, &event.inline_attachment_media); - opt_modify(&mut settings.inline_embed_media, &event.inline_embed_media); - opt_modify(&mut settings.locale, &event.locale); - opt_modify(&mut settings.message_display_compact, &event.message_display_compact); - opt_modify(&mut settings.render_embeds, &event.render_embeds); - opt_modify(&mut settings.show_current_game, &event.show_current_game); - opt_modify(&mut settings.theme, &event.theme); - opt_modify(&mut settings.convert_emoticons, &event.convert_emoticons); - opt_modify(&mut settings.friend_source_flags, &event.friend_source_flags); - }); - - item - } - - #[doc(hidden)] pub fn update_with_user_update(&mut self, event: &UserUpdateEvent) -> CurrentUser { mem::replace(&mut self.user, event.current_user.clone()) } @@ -1126,13 +1036,10 @@ impl Default for Cache { calls: HashMap::default(), channels: HashMap::default(), groups: HashMap::default(), - guild_settings: HashMap::default(), guilds: HashMap::default(), notes: HashMap::default(), presences: HashMap::default(), private_channels: HashMap::default(), - relationships: HashMap::default(), - settings: None, unavailable_guilds: HashSet::default(), user: CurrentUser { avatar: None, @@ -1141,7 +1048,6 @@ impl Default for Cache { email: None, id: UserId(0), mfa_enabled: false, - mobile: None, name: String::default(), verified: false, }, @@ -1149,9 +1055,3 @@ impl Default for Cache { } } } - -fn opt_modify<T: Clone>(dest: &mut T, src: &Option<T>) { - if let Some(val) = src.as_ref() { - dest.clone_from(val); - } -} |