Skip to content

Commit

Permalink
Fix compilation errors that arose from rebasing
Browse files Browse the repository at this point in the history
Additionally, adapt some code to the `next` branch.
  • Loading branch information
arqunis committed Jul 20, 2022
1 parent c41e74d commit b6d6ce0
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 41 deletions.
10 changes: 2 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bitflags = "1.3"
serde_json = "1.0.75"
serde-value = "0.7"
async-trait = "0.1.9"
rustversion = "1.0.7"

[dependencies.nougat]
version = "0.2.0"
Expand All @@ -29,10 +30,6 @@ optional = true
version = "2.2.0"
optional = true

[dependencies.rustversion]
version = "1.0.7"
optional = true

[dependencies.simd-json]
version = "0.4.14"
optional = true
Expand Down Expand Up @@ -177,7 +174,7 @@ default_no_backend = [

builder = ["utils"]
cache = ["dashmap", "parking_lot"]
collector = ["gateway", "model", "rustversion", "derivative", "nougat"]
collector = ["gateway", "model", "derivative", "nougat"]
client = ["http", "typemap_rev"]
extras = []
framework = ["client", "model", "utils"]
Expand Down Expand Up @@ -216,9 +213,6 @@ native_tls_backend = [
"bytes",
]

# TODO(next): Remove, these are deprecated aliases
simdjson = ["simd_json"]
voice-model = ["voice_model"]

[package.metadata.docs.rs]
features = ["default", "collector", "unstable_discord_api", "voice", "voice-model"]
Expand Down
17 changes: 1 addition & 16 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,4 @@ compile_error!(
If you are unsure, go with `rustls_backend`."
);

#[cfg_attr(
feature = "simdjson",
deprecated = "The `simdjson` feature name is deprecated and will be removed in the next version of serenity, use `simd_json`."
)]
fn deprecated_simd_json_feature() {}

#[cfg_attr(
feature = "voice-model",
deprecated = "The `voice-model` feature name is deprecated and will be removed in the next version of serenity, use `voice_model`."
)]
fn deprecated_voice_model_feature() {}

fn main() {
deprecated_simd_json_feature();
deprecated_voice_model_feature()
}
fn main() {}
8 changes: 6 additions & 2 deletions src/builder/create_application_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ pub struct CreateApplicationCommandOption {
min_value: Option<Number>,
#[serde(skip_serializing_if = "Option::is_none")]
max_value: Option<Number>,
#[serde(skip_serializing_if = "Option::is_none")]
min_length: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
max_length: Option<u16>,

channel_types: Vec<ChannelType>,
choices: Vec<CommandOptionChoice>,
Expand Down Expand Up @@ -290,7 +294,7 @@ impl CreateApplicationCommandOption {
///
/// The value of `min_length` must be greater or equal to `0`.
pub fn min_length(&mut self, value: u16) -> &mut Self {
self.0.insert("min_length", value.into());
self.min_length = Some(value);

self
}
Expand All @@ -299,7 +303,7 @@ impl CreateApplicationCommandOption {
///
/// The value of `max_length` must be greater or equal to `1`.
pub fn max_length(&mut self, value: u16) -> &mut Self {
self.0.insert("max_length", value.into());
self.max_length = Some(value);

self
}
Expand Down
4 changes: 2 additions & 2 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,7 @@ impl Http {
let body = to_vec(&map)?;

self.fire(Request {
body: Some(&body),
body: Some(body),
multipart: None,
headers: None,
route: RouteInfo::CreateAutoModRule {
Expand All @@ -2472,7 +2472,7 @@ impl Http {
let body = to_vec(&map)?;

self.fire(Request {
body: Some(&body),
body: Some(body),
multipart: None,
headers: None,
route: RouteInfo::EditAutoModRule {
Expand Down
1 change: 0 additions & 1 deletion src/model/channel/guild_channel.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::fmt;
#[cfg(feature = "model")]
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/automod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ mod tests {
Token::StructEnd,
]);

let value = Action::Alert(ChannelId(123));
let value = Action::Alert(ChannelId::new(123));
serde_test::assert_tokens(&value, &[
Token::Struct {
name: "Action",
Expand Down
14 changes: 7 additions & 7 deletions src/model/guild/guild_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::http::{CacheHttp, Http, UserPagination};
#[cfg(feature = "model")]
use crate::internal::prelude::*;
#[cfg(feature = "model")]
use crate::json::json;
use crate::json::{self, json};
#[cfg(feature = "model")]
use crate::model::application::command::{Command, CommandPermission};
#[cfg(feature = "model")]
Expand All @@ -53,7 +53,7 @@ impl GuildId {
/// [Manage Guild]: Permissions::MANAGE_GUILD
#[inline]
pub async fn automod_rules(self, http: impl AsRef<Http>) -> Result<Vec<Rule>> {
http.as_ref().get_automod_rules(self.0).await
http.as_ref().get_automod_rules(self.get()).await
}

/// Gets an auto moderation [`Rule`] of this guild by its ID via HTTP.
Expand All @@ -71,7 +71,7 @@ impl GuildId {
http: impl AsRef<Http>,
rule_id: impl Into<RuleId>,
) -> Result<Rule> {
http.as_ref().get_automod_rule(self.0, rule_id.into().0).await
http.as_ref().get_automod_rule(self.get(), rule_id.into().0.get()).await
}

/// Creates an auto moderation [`Rule`] in the guild.
Expand All @@ -91,7 +91,7 @@ impl GuildId {
/// # async fn run() {
/// # use serenity::http::Http;
/// # let http = Http::new("token");
/// let _rule = GuildId(7)
/// let _rule = GuildId::new(7)
/// .create_automod_rule(&http, |r| {
/// r.name("foobar filter")
/// .trigger(Trigger::Keyword(vec!["foo*".to_string(), "*bar".to_string()]))
Expand All @@ -118,7 +118,7 @@ impl GuildId {

let map = json::hashmap_to_json_map(builder.0);

http.as_ref().create_automod_rule(self.0, &map).await
http.as_ref().create_automod_rule(self.get(), &map).await
}

/// Edit an auto moderation [`Rule`] by its ID.
Expand All @@ -143,7 +143,7 @@ impl GuildId {

let map = json::hashmap_to_json_map(builder.0);

http.as_ref().edit_automod_rule(self.0, rule_id.into().0, &map).await
http.as_ref().edit_automod_rule(self.get(), rule_id.into().0.get(), &map).await
}

/// Deletes an auto moderation [`Rule`] from the guild.
Expand All @@ -162,7 +162,7 @@ impl GuildId {
http: impl AsRef<Http>,
rule_id: impl Into<RuleId>,
) -> Result<()> {
http.as_ref().delete_automod_rule(self.0, rule_id.into().0).await
http.as_ref().delete_automod_rule(self.get(), rule_id.into().0.get()).await
}

/// Adds a [`User`] to this guild with a valid OAuth2 access token.
Expand Down
6 changes: 2 additions & 4 deletions src/model/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ pub struct MessageId(#[serde(with = "snowflake")] pub NonZeroU64);
pub struct RoleId(#[serde(with = "snowflake")] pub NonZeroU64);

/// An identifier for an auto moderation rule
#[derive(
Copy, Clone, Default, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Deserialize, Serialize,
)]
pub struct RuleId(#[serde(with = "snowflake")] pub u64);
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Deserialize, Serialize)]
pub struct RuleId(#[serde(with = "snowflake")] pub NonZeroU64);

/// An identifier for a Scheduled Event
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
Expand Down

0 comments on commit b6d6ce0

Please sign in to comment.