Gateway: Generic Shard and Twilight v0.8 Support (#109)
This PR adds support for twilight v0.8, mainly adapting to significant API changes introduced by v0.7. As a result of these, twilight no longer accepts arbitrary JSON input, so it seemed sensible to adapt our `Shard` design to no longer require the same. Adding to this, I've added in a trait to allow an arbitrary `Shard` to be installed, given only an implementation of a method to send a `VoiceStateUpdate`. Together, `Sharder::Generic` (songbird::shards::VoiceUpdate) and `Shard::Generic` (songbird::shards::GenericSharder) should allow any library to be hooked in to Songbird. This PR was tested using `cargo make ready` and by manually testing `examples/twilight`.
This commit is contained in:
@@ -5,11 +5,10 @@ use crate::{
|
||||
id::{ChannelId, GuildId, UserId},
|
||||
info::{ConnectionInfo, ConnectionProgress},
|
||||
join::*,
|
||||
shards::Shard,
|
||||
shards::{Shard, VoiceUpdate},
|
||||
Config,
|
||||
};
|
||||
use flume::Sender;
|
||||
use serde_json::json;
|
||||
use std::fmt::Debug;
|
||||
use tracing::instrument;
|
||||
|
||||
@@ -448,17 +447,13 @@ impl Call {
|
||||
#[instrument(skip(self))]
|
||||
async fn update(&mut self) -> JoinResult<()> {
|
||||
if let Some(ws) = self.ws.as_mut() {
|
||||
let map = json!({
|
||||
"op": 4,
|
||||
"d": {
|
||||
"channel_id": self.connection.as_ref().map(|c| c.0.channel_id().0),
|
||||
"guild_id": self.guild_id.0,
|
||||
"self_deaf": self.self_deaf,
|
||||
"self_mute": self.self_mute,
|
||||
}
|
||||
});
|
||||
|
||||
ws.send(map).await
|
||||
ws.update_voice_state(
|
||||
self.guild_id,
|
||||
self.connection.as_ref().map(|c| c.0.channel_id()),
|
||||
self.self_deaf,
|
||||
self.self_mute,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
Err(JoinError::NoSender)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user