diff --git a/Cargo.toml b/Cargo.toml index 7acbd87a9e4..8c7eda843f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,6 @@ chrono = { version = "0.4.31", default-features = false, features = ["clock", "s flate2 = { version = "1.0.28", optional = true } zstd-safe = { version = "7.2.1", optional = true } reqwest = { version = "0.12.2", default-features = false, features = ["multipart", "stream", "json"], optional = true } -tokio-tungstenite = { version = "0.24.0", features = ["url"], optional = true } percent-encoding = { version = "2.3.0", optional = true } mini-moka = { version = "0.10.2", optional = true } mime_guess = { version = "2.0.4", optional = true } @@ -66,6 +65,7 @@ typesize = { version = "0.1.6", optional = true, features = ["url", "time", "ser # serde feature only allows for serialisation, # Serenity workspace crates serenity-voice-model = { version = "0.2.0", path = "./voice-model", optional = true } +tokio-tungstenite = { version = "0.26.1", features = ["url"], optional = true } [dev-dependencies.http_crate] version = "1.1.0" diff --git a/src/builder/create_command.rs b/src/builder/create_command.rs index 281eada6845..2fd468d1a35 100644 --- a/src/builder/create_command.rs +++ b/src/builder/create_command.rs @@ -344,7 +344,6 @@ impl<'a> CreateCommand<'a> { Self { kind: None, handler: None, - fields: EditCommand::new().name(name), } } diff --git a/src/gateway/error.rs b/src/gateway/error.rs index 7bc0a3c28d0..2c16c1a65b3 100644 --- a/src/gateway/error.rs +++ b/src/gateway/error.rs @@ -13,7 +13,7 @@ pub enum Error { /// There was an error building a URL. BuildingUrl, /// The connection closed, potentially uncleanly. - Closed(Option>), + Closed(Option), /// Expected a Hello during a handshake ExpectedHello, /// When there was an error sending a heartbeat. diff --git a/src/gateway/sharding/mod.rs b/src/gateway/sharding/mod.rs index a892a467c89..e9a499c5bef 100644 --- a/src/gateway/sharding/mod.rs +++ b/src/gateway/sharding/mod.rs @@ -383,7 +383,7 @@ impl Shard { } #[cfg_attr(feature = "tracing_instrument", instrument(skip(self)))] - fn handle_gateway_closed(&mut self, data: Option<&CloseFrame<'static>>) -> Result<()> { + fn handle_gateway_closed(&mut self, data: Option<&CloseFrame>) -> Result<()> { if let Some(code) = data.map(|d| d.code) { match CloseCode(code.into()) { CloseCode::UnknownError => warn!("[{:?}] Unknown gateway error.", self.shard_info), diff --git a/src/gateway/sharding/shard_runner.rs b/src/gateway/sharding/shard_runner.rs index aaaacca847b..df2f76d4cac 100644 --- a/src/gateway/sharding/shard_runner.rs +++ b/src/gateway/sharding/shard_runner.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use std::sync::Arc; use futures::channel::mpsc::{self, UnboundedReceiver as Receiver, UnboundedSender as Sender}; @@ -245,7 +244,7 @@ impl ShardRunner { .client .close(Some(CloseFrame { code: close_code.into(), - reason: Cow::from(""), + reason: "".into(), })) .await, ); @@ -308,7 +307,7 @@ impl ShardRunner { let reason = reason.unwrap_or_default(); let close = CloseFrame { code: code.into(), - reason: Cow::from(reason), + reason: reason.into(), }; self.shard.client.close(Some(close)).await.is_ok() }, diff --git a/src/gateway/ws.rs b/src/gateway/ws.rs index d88a1b569f7..5fcb4a98b2a 100644 --- a/src/gateway/ws.rs +++ b/src/gateway/ws.rs @@ -228,11 +228,9 @@ const TIMEOUT: Duration = Duration::from_millis(500); impl WsClient { pub(crate) async fn connect(url: Url, compression: TransportCompression) -> Result { - let config = WebSocketConfig { - max_message_size: None, - max_frame_size: None, - ..Default::default() - }; + let mut config = WebSocketConfig::default(); + config.max_message_size = None; + config.max_frame_size = None; let (stream, _) = connect_async_with_config(url, Some(config), false).await?; Ok(Self { @@ -249,7 +247,7 @@ impl WsClient { }; let json_bytes = match message { - Message::Text(payload) => Cow::Owned(payload.into_bytes()), + Message::Text(payload) => Cow::Owned((payload.as_ref() as &[u8]).to_vec()), Message::Binary(bytes) => { let Some(decompressed) = self.compression.inflate(&bytes)? else { return Ok(None); @@ -284,7 +282,7 @@ impl WsClient { } pub(crate) async fn send_json(&mut self, value: &impl serde::Serialize) -> Result<()> { - let message = serde_json::to_string(value).map(Message::Text)?; + let message = Message::Text(serde_json::to_string(value)?.into()); self.stream.send(message).await?; Ok(()) @@ -302,7 +300,7 @@ impl WsClient { } /// Delegate to `WebSocketStream::close` - pub(crate) async fn close(&mut self, msg: Option>) -> Result<()> { + pub(crate) async fn close(&mut self, msg: Option) -> Result<()> { self.stream.close(msg).await?; Ok(()) } diff --git a/src/model/error.rs b/src/model/error.rs index f97f4dad0b5..d82b608a59d 100644 --- a/src/model/error.rs +++ b/src/model/error.rs @@ -235,11 +235,15 @@ impl fmt::Display for Error { Self::TooSmall { minimum, value, - } => write!(f, "The {minimum} minimum has been missed by {value}"), + } => { + write!(f, "The {minimum} minimum has been missed by {value}") + }, Self::TooLarge { maximum, value, - } => write!(f, "The {maximum} maximum has been overflowed by {value}"), + } => { + write!(f, "The {maximum} maximum has been overflowed by {value}") + }, Self::GuildNotFound => f.write_str("Guild not found in the cache."), Self::RoleNotFound => f.write_str("Role not found in the cache."), Self::MemberNotFound => f.write_str("Member not found in the cache."),