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/model/utils.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/model/utils.rs')
| -rw-r--r-- | src/model/utils.rs | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/src/model/utils.rs b/src/model/utils.rs index 17f91f1..cbae244 100644 --- a/src/model/utils.rs +++ b/src/model/utils.rs @@ -30,36 +30,6 @@ pub fn decode_emojis(value: Value) -> Result<HashMap<EmojiId, Emoji>> { Ok(emojis) } -pub fn decode_experiments(value: Value) -> Result<Vec<Vec<u64>>> { - let array = match value { - Value::Array(v) => v, - value => return Err(Error::Decode("Expected experiment array", value)), - }; - - let mut experiments: Vec<Vec<u64>> = vec![]; - - for arr in array { - let arr = match arr { - Value::Array(v) => v, - value => return Err(Error::Decode("Expected experiment's array", value)), - }; - - let mut items: Vec<u64> = vec![]; - - for item in arr { - items.push(match item { - Value::I64(v) => v as u64, - Value::U64(v) => v, - value => return Err(Error::Decode("Expected experiment u64", value)), - }); - } - - experiments.push(items); - } - - Ok(experiments) -} - pub fn decode_id(value: Value) -> Result<u64> { match value { Value::U64(num) => Ok(num), @@ -102,25 +72,6 @@ pub fn decode_guild_members(guild_id: GuildId, value: Value) -> Result<HashMap<U Ok(members) } -// Clippy's lint is incorrect here and will result in invalid code. -// -// Bit more detaul: `result_unwrap_or_default` is not yet stable as of rustc -// 1.14. -#[allow(or_fun_call)] -pub fn decode_notes(value: Value) -> Result<HashMap<UserId, String>> { - let mut notes = HashMap::new(); - - for (key, value) in into_map(value).unwrap_or(BTreeMap::default()) { - let id = UserId(key.parse::<u64>() - .map_err(|_| Error::Decode("Invalid user id in notes", - Value::String(key)))?); - - notes.insert(id, into_string(value)?); - } - - Ok(notes) -} - pub fn decode_presences(value: Value) -> Result<HashMap<UserId, Presence>> { let mut presences = HashMap::new(); @@ -148,28 +99,6 @@ pub fn decode_private_channels(value: Value) Ok(private_channels) } -pub fn decode_read_states(value: Value) - -> Result<HashMap<ChannelId, ReadState>> { - let mut read_states = HashMap::new(); - - for read_state in decode_array(value, ReadState::decode)? { - read_states.insert(read_state.id, read_state); - } - - Ok(read_states) -} - -pub fn decode_relationships(value: Value) - -> Result<HashMap<UserId, Relationship>> { - let mut relationships = HashMap::new(); - - for relationship in decode_array(value, Relationship::decode)? { - relationships.insert(relationship.id, relationship); - } - - Ok(relationships) -} - pub fn decode_roles(value: Value) -> Result<HashMap<RoleId, Role>> { let mut roles = HashMap::new(); @@ -180,35 +109,6 @@ pub fn decode_roles(value: Value) -> Result<HashMap<RoleId, Role>> { Ok(roles) } -pub fn decode_search_results(value: Value) -> Result<Vec<Vec<Message>>> { - let array = match value { - Value::Array(v) => v, - value => return Err(Error::Decode("Expected message set array", value)), - }; - - let mut sets: Vec<Vec<Message>> = vec![]; - - for arr in array { - let arr = match arr { - Value::Array(v) => v, - value => return Err(Error::Decode("Expected message set array", value)), - }; - - let mut messages: Vec<Message> = vec![]; - - for item in arr { - messages.push(match item { - Value::Object(v) => try!(Message::decode(Value::Object(v))), - value => return Err(Error::Decode("Expected search message", value)), - }); - } - - sets.push(messages); - } - - Ok(sets) -} - pub fn decode_shards(value: Value) -> Result<[u64; 2]> { let array = into_array(value)?; |