From d3a40fe6913c39f866a3c8deea860a314eac009b Mon Sep 17 00:00:00 2001 From: Kyle Simpson Date: Sun, 24 Apr 2022 11:23:44 +0100 Subject: [PATCH] Examples: support new Serenity Intents init Fixes up the serenity examples to account for a bunch of API changes on `next`/v0.11. Tested using `cargo make ready`. --- examples/serenity/voice/src/main.rs | 6 +++++- examples/serenity/voice_events_queue/src/main.rs | 8 ++++++-- examples/serenity/voice_receive/src/main.rs | 7 +++++-- examples/serenity/voice_storage/src/main.rs | 9 ++++++--- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/examples/serenity/voice/src/main.rs b/examples/serenity/voice/src/main.rs index 83f017041..8afcd25fc 100644 --- a/examples/serenity/voice/src/main.rs +++ b/examples/serenity/voice/src/main.rs @@ -27,6 +27,7 @@ use serenity::{ }, }, model::{channel::Message, gateway::Ready}, + prelude::GatewayIntents, Result as SerenityResult, }; @@ -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() diff --git a/examples/serenity/voice_events_queue/src/main.rs b/examples/serenity/voice_events_queue/src/main.rs index c9845b201..7a78d0da4 100644 --- a/examples/serenity/voice_events_queue/src/main.rs +++ b/examples/serenity/voice_events_queue/src/main.rs @@ -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, }; @@ -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() diff --git a/examples/serenity/voice_receive/src/main.rs b/examples/serenity/voice_receive/src/main.rs index ca202513e..bff1dbb11 100644 --- a/examples/serenity/voice_receive/src/main.rs +++ b/examples/serenity/voice_receive/src/main.rs @@ -22,8 +22,8 @@ use serenity::{ channel::Message, gateway::Ready, id::ChannelId, - misc::Mentionable }, + prelude::{GatewayIntents, Mentionable}, Result as SerenityResult, }; @@ -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) diff --git a/examples/serenity/voice_storage/src/main.rs b/examples/serenity/voice_storage/src/main.rs index 8c56ea067..f5c9c539b 100644 --- a/examples/serenity/voice_storage/src/main.rs +++ b/examples/serenity/voice_storage/src/main.rs @@ -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, }; @@ -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()