Skip to content

Commit

Permalink
Fix compiling with latest serenity (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev authored Oct 9, 2023
1 parent efe2a0b commit 87bd3ab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
3 changes: 2 additions & 1 deletion examples/serenity/voice/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ use serenity::{
framework::{
standard::{
macros::{command, group},
Args, CommandResult,
Args,
CommandResult,
},
StandardFramework,
},
Expand Down
15 changes: 6 additions & 9 deletions examples/serenity/voice_receive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,13 @@ async fn main() {
#[command]
#[only_in(guilds)]
async fn join(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let connect_to = match args.single::<std::num::NonZeroU64>() {
Ok(id) => ChannelId(id),
Err(_) => {
check_msg(
msg.reply(ctx, "Requires a valid voice channel ID be given")
.await,
);
let Ok(connect_to) = args.single::<ChannelId>() else {
check_msg(
msg.reply(ctx, "Requires a valid voice channel ID be given")
.await,
);

return Ok(());
},
return Ok(());
};

let guild_id = msg.guild_id.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl From<NonZeroU64> for ChannelId {
#[cfg(feature = "serenity")]
impl From<SerenityChannel> for ChannelId {
fn from(id: SerenityChannel) -> Self {
Self(id.0)
Self(NonZeroU64::new(id.get()).unwrap())
}
}

Expand All @@ -71,7 +71,7 @@ impl From<NonZeroU64> for GuildId {
#[cfg(feature = "serenity")]
impl From<SerenityGuild> for GuildId {
fn from(id: SerenityGuild) -> Self {
Self(id.0)
Self(NonZeroU64::new(id.get()).unwrap())
}
}

Expand Down Expand Up @@ -104,7 +104,7 @@ impl From<NonZeroU64> for UserId {
#[cfg(feature = "serenity")]
impl From<SerenityUser> for UserId {
fn from(id: SerenityUser) -> Self {
Self(id.0)
Self(NonZeroU64::new(id.get()).unwrap())
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,9 @@ impl VoiceGatewayManager for Songbird {
}

async fn state_update(&self, guild_id: SerenityGuild, voice_state: &VoiceState) {
if self
.client_data
.get()
.map_or(true, |data| voice_state.user_id.0 != data.user_id.0)
{
if self.client_data.get().map_or(true, |data| {
voice_state.user_id.get() != data.user_id.0.get()
}) {
return;
}

Expand Down

0 comments on commit 87bd3ab

Please sign in to comment.