aboutsummaryrefslogtreecommitdiff
path: root/src/model/user.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-04-05 08:14:43 -0700
committerZeyla Hellyer <[email protected]>2017-04-05 08:55:01 -0700
commitd9118c081742d6654dc0a4f60228a7a212ca436e (patch)
tree003f49f54769314c1111e942d77f57513406fb5e /src/model/user.rs
parentAdd a sample bot structure example (diff)
downloadserenity-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/model/user.rs')
-rw-r--r--src/model/user.rs109
1 files changed, 1 insertions, 108 deletions
diff --git a/src/model/user.rs b/src/model/user.rs
index c69cf39..338011b 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -1,18 +1,14 @@
use serde_json::builder::ObjectBuilder;
use std::{fmt, mem};
-use super::utils::{into_map, into_string, remove};
use super::{
CurrentUser,
- FriendSourceFlags,
GuildContainer,
GuildId,
GuildInfo,
Member,
Message,
- OnlineStatus,
PrivateChannel,
RoleId,
- UserSettings,
User,
UserId,
};
@@ -21,7 +17,6 @@ use ::client::rest::{self, GuildPagination};
use ::internal::prelude::*;
use ::model::misc::Mentionable;
use ::utils::builder::EditProfile;
-use ::utils::decode_array;
#[cfg(feature="cache")]
use std::sync::{Arc, RwLock};
@@ -159,24 +154,6 @@ impl User {
Ok(cdn!("/embed/avatars/{}.png", self.discriminator.parse::<u16>()? % 5u16).to_owned())
}
- /// Deletes a profile note from a user.
- ///
- /// # Examples
- ///
- /// Delete a note for a [`Message`]'s author:
- ///
- /// ```rust,ignore
- /// // assuming you are in a context
- ///
- /// let _ = message.author.delete_note();
- /// ```
- ///
- /// [`Message`]: struct.Message.html
- #[inline]
- pub fn delete_note(&self) -> Result<()> {
- self.id.delete_note()
- }
-
/// Sends a message to a user through a direct message channel. This is a
/// channel that can only be accessed by you and the recipient.
///
@@ -266,35 +243,6 @@ impl User {
self.direct_message(content)
}
- /// Edits the note that the current user has set for another user.
- ///
- /// Use [`delete_note`] to remove a note.
- ///
- /// **Note**: Requires that the current user be a user account.
- ///
- /// # Examples
- ///
- /// Set a note for a message's author:
- ///
- /// ```rust,ignore
- /// // assuming a `message` has been bound
- ///
- /// let _ = message.author.edit_note("test note");
- /// ```
- ///
- /// # Errors
- ///
- /// If the `cache` is enabled, returns a
- /// [`ClientError::InvalidOperationAsBot`] if the current user is a bot
- /// user.
- ///
- /// [`ClientError::InvalidOperationAsBot`]: ../client/enum.ClientError.html#variant.InvalidOperationAsBot
- /// [`delete_note`]: #method.delete_note
- #[inline]
- pub fn edit_note(&self, note: &str) -> Result<()> {
- self.id.edit_note(note)
- }
-
/// Gets a user by its Id over the REST API.
///
/// **Note**: The current user must be a bot user.
@@ -306,14 +254,8 @@ impl User {
/// user.
///
/// [`ClientError::InvalidOperationAsUser`]: ../client/enum.ClientError.html#variant.InvalidOperationAsUser
+ #[inline]
pub fn get<U: Into<UserId>>(user_id: U) -> Result<User> {
- #[cfg(feature="cache")]
- {
- if !CACHE.read().unwrap().user.bot {
- return Err(Error::Client(ClientError::InvalidOperationAsUser));
- }
- }
-
user_id.into().get()
}
@@ -389,29 +331,6 @@ impl UserId {
rest::create_private_channel(&map)
}
- /// Deletes a profile note from a user.
- pub fn delete_note(&self) -> Result<()> {
- let map = ObjectBuilder::new().insert("note", "").build();
-
- rest::edit_note(self.0, &map)
- }
-
- /// Edits the note that the current user has set for another user.
- ///
- /// Use [`delete_note`] to remove a note.
- ///
- /// Refer to the documentation for [`User::edit_note`] for more information.
- ///
- /// **Note**: Requires that the current user be a user account.
- ///
- /// [`delete_note`]: #method.delete_note
- /// [`User::edit_note`]: struct.User.html#method.edit_note
- pub fn edit_note(&self, note: &str) -> Result<()> {
- let map = ObjectBuilder::new().insert("note", note).build();
-
- rest::edit_note(self.0, &map)
- }
-
/// Search the cache for the user with the Id.
#[cfg(feature="cache")]
pub fn find(&self) -> Option<Arc<RwLock<User>>> {
@@ -453,29 +372,3 @@ impl fmt::Display for UserId {
fmt::Display::fmt(&self.0, f)
}
}
-
-impl UserSettings {
- #[doc(hidden)]
- pub fn decode(value: Value) -> Result<Option<UserSettings>> {
- let mut map = into_map(value)?;
-
- if map.is_empty() {
- return Ok(None);
- }
-
- Ok(UserSettings {
- convert_emoticons: req!(remove(&mut map, "convert_emoticons")?.as_bool()),
- enable_tts_command: req!(remove(&mut map, "enable_tts_command")?.as_bool()),
- friend_source_flags: remove(&mut map, "friend_source_flags").and_then(FriendSourceFlags::decode)?,
- inline_attachment_media: req!(remove(&mut map, "inline_attachment_media")?.as_bool()),
- inline_embed_media: req!(remove(&mut map, "inline_embed_media")?.as_bool()),
- locale: remove(&mut map, "locale").and_then(into_string)?,
- message_display_compact: req!(remove(&mut map, "message_display_compact")?.as_bool()),
- render_embeds: req!(remove(&mut map, "render_embeds")?.as_bool()),
- restricted_guilds: remove(&mut map, "restricted_guilds").and_then(|v| decode_array(v, GuildId::decode))?,
- show_current_game: req!(remove(&mut map, "show_current_game")?.as_bool()),
- theme: remove(&mut map, "theme").and_then(into_string)?,
- status: remove(&mut map, "status").and_then(OnlineStatus::decode_str)?,
- }).map(Some)
- }
-}