Skip to content

Commit

Permalink
Examples: support new Serenity Intents init
Browse files Browse the repository at this point in the history
Fixes up the serenity examples to account for a bunch of API changes on `next`/v0.11.

Tested using `cargo make ready`.
  • Loading branch information
FelixMcFelix committed Jul 22, 2022
1 parent e3476e7 commit d3a40fe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
6 changes: 5 additions & 1 deletion examples/serenity/voice/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use serenity::{
},
},
model::{channel::Message, gateway::Ready},
prelude::GatewayIntents,
Result as SerenityResult,
};

Expand Down Expand Up @@ -56,7 +57,10 @@ async fn main() {
.prefix("~"))
.group(&GENERAL_GROUP);

let mut client = Client::builder(&token)
let intents = GatewayIntents::non_privileged()
| GatewayIntents::MESSAGE_CONTENT;

let mut client = Client::builder(&token, intents)
.event_handler(Handler)
.framework(framework)
.register_songbird()
Expand Down
8 changes: 6 additions & 2 deletions examples/serenity/voice_events_queue/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use serenity::{
StandardFramework,
},
http::Http,
model::{channel::Message, gateway::Ready, misc::Mentionable, prelude::ChannelId},
model::{channel::Message, gateway::Ready, prelude::ChannelId},
prelude::{GatewayIntents, Mentionable},
Result as SerenityResult,
};

Expand Down Expand Up @@ -72,7 +73,10 @@ async fn main() {
.configure(|c| c.prefix("~"))
.group(&GENERAL_GROUP);

let mut client = Client::builder(&token)
let intents = GatewayIntents::non_privileged()
| GatewayIntents::MESSAGE_CONTENT;

let mut client = Client::builder(&token, intents)
.event_handler(Handler)
.framework(framework)
.register_songbird()
Expand Down
7 changes: 5 additions & 2 deletions examples/serenity/voice_receive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use serenity::{
channel::Message,
gateway::Ready,
id::ChannelId,
misc::Mentionable
},
prelude::{GatewayIntents, Mentionable},
Result as SerenityResult,
};

Expand Down Expand Up @@ -151,13 +151,16 @@ async fn main() {
.prefix("~"))
.group(&GENERAL_GROUP);

let intents = GatewayIntents::non_privileged()
| GatewayIntents::MESSAGE_CONTENT;

// Here, we need to configure Songbird to decode all incoming voice packets.
// If you want, you can do this on a per-call basis---here, we need it to
// read the audio data that other people are sending us!
let songbird_config = Config::default()
.decode_mode(DecodeMode::Decode);

let mut client = Client::builder(&token)
let mut client = Client::builder(&token, intents)
.event_handler(Handler)
.framework(framework)
.register_songbird_from_config(songbird_config)
Expand Down
9 changes: 6 additions & 3 deletions examples/serenity/voice_storage/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use serenity::{
macros::{command, group},
},
},
model::{channel::Message, gateway::Ready, misc::Mentionable},
prelude::Mutex,
model::{channel::Message, gateway::Ready},
prelude::{GatewayIntents, Mentionable, Mutex},
Result as SerenityResult,
};

Expand Down Expand Up @@ -94,7 +94,10 @@ async fn main() {
.prefix("~"))
.group(&GENERAL_GROUP);

let mut client = Client::builder(&token)
let intents = GatewayIntents::non_privileged()
| GatewayIntents::MESSAGE_CONTENT;

let mut client = Client::builder(&token, intents)
.event_handler(Handler)
.framework(framework)
.register_songbird()
Expand Down

0 comments on commit d3a40fe

Please sign in to comment.