Skip to content

Commit

Permalink
Examples: Fix serenity-next cache accesses (#99)
Browse files Browse the repository at this point in the history
Serenity's cache design has changed, this (finally) prevents the examples from failing to compile on CI.
  • Loading branch information
FelixMcFelix committed Jul 22, 2022
1 parent 67ad7c9 commit f1ed41e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions examples/serenity/voice/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async fn main() {
#[command]
#[only_in(guilds)]
async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand Down Expand Up @@ -107,7 +107,7 @@ async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn join(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let channel_id = guild
Expand All @@ -134,7 +134,7 @@ async fn join(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand All @@ -157,7 +157,7 @@ async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn mute(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand Down Expand Up @@ -212,7 +212,7 @@ async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
return Ok(());
}

let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand Down Expand Up @@ -245,7 +245,7 @@ async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn undeafen(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand All @@ -268,7 +268,7 @@ async fn undeafen(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn unmute(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand Down
20 changes: 10 additions & 10 deletions examples/serenity/voice_events_queue/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async fn main() {

#[command]
async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx)
Expand Down Expand Up @@ -126,7 +126,7 @@ async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn join(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let channel_id = guild
Expand Down Expand Up @@ -241,7 +241,7 @@ impl VoiceEventHandler for ChannelDurationNotifier {
#[command]
#[only_in(guilds)]
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx)
Expand Down Expand Up @@ -270,7 +270,7 @@ async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn mute(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx)
Expand Down Expand Up @@ -339,7 +339,7 @@ async fn play_fade(ctx: &Context, msg: &Message, mut args: Args) -> CommandResul
return Ok(());
}

let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx)
Expand Down Expand Up @@ -470,7 +470,7 @@ async fn queue(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
return Ok(());
}

let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx)
Expand Down Expand Up @@ -518,7 +518,7 @@ async fn queue(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn skip(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx)
Expand Down Expand Up @@ -553,7 +553,7 @@ async fn skip(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn stop(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx)
Expand Down Expand Up @@ -581,7 +581,7 @@ async fn stop(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn undeafen(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx)
Expand Down Expand Up @@ -614,7 +614,7 @@ async fn undeafen(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn unmute(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;
let manager = songbird::get(ctx)
.await
Expand Down
4 changes: 2 additions & 2 deletions examples/serenity/voice_receive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async fn join(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
},
};

let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand Down Expand Up @@ -227,7 +227,7 @@ async fn join(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand Down
14 changes: 7 additions & 7 deletions examples/serenity/voice_storage/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async fn main() {
#[command]
#[only_in(guilds)]
async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand Down Expand Up @@ -184,7 +184,7 @@ async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn join(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let channel_id = guild
Expand Down Expand Up @@ -262,7 +262,7 @@ impl VoiceEventHandler for LoopPlaySound {
#[command]
#[only_in(guilds)]
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand All @@ -285,7 +285,7 @@ async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn mute(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand Down Expand Up @@ -318,7 +318,7 @@ async fn mute(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn ting(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand All @@ -344,7 +344,7 @@ async fn ting(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn undeafen(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;

let manager = songbird::get(ctx).await
Expand All @@ -368,7 +368,7 @@ async fn undeafen(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
#[only_in(guilds)]
async fn unmute(ctx: &Context, msg: &Message) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let guild = msg.guild(&ctx.cache).unwrap();
let guild_id = guild.id;
let manager = songbird::get(ctx).await
.expect("Songbird Voice client placed in at initialisation.").clone();
Expand Down

0 comments on commit f1ed41e

Please sign in to comment.