diff --git a/Cargo.toml b/Cargo.toml index 9b7bb92..9fa8013 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" music = ["serenity/voice", "songbird"] [dependencies] -serenity = { version = "0.10", features = ["unstable_discord_api"] } +serenity = { version = "0.10.9", features = ["unstable_discord_api"] } toml = "0.5" serde = { version = "1.0", features = ["derive"] } reqwest = "0.11" diff --git a/src/commands/general.rs b/src/commands/general.rs index fba1293..872ee15 100644 --- a/src/commands/general.rs +++ b/src/commands/general.rs @@ -1,16 +1,10 @@ use crate::{api, data::ShardManagerContainer}; use futures::StreamExt; use log::error; -use serenity::{ - client::bridge::gateway::ShardId, - framework::standard::{ +use serenity::{client::bridge::gateway::ShardId, framework::standard::{ macros::{command, group}, ArgError, Args, CommandResult, - }, - http::CacheHttp, - model::prelude::*, - prelude::*, -}; + }, http::CacheHttp, model::{interactions::message_component::ButtonStyle, prelude::*}, prelude::*}; #[group] #[commands( diff --git a/src/commands/interaction.rs b/src/commands/interaction.rs index 2ff6040..8a20d78 100644 --- a/src/commands/interaction.rs +++ b/src/commands/interaction.rs @@ -4,9 +4,12 @@ use serenity::{ model::{ guild::Member, interactions::{ - ApplicationCommandInteractionData, Interaction, - InteractionApplicationCommandCallbackDataFlags, InteractionData, - InteractionResponseType, MessageComponent, + application_command::{ + ApplicationCommandInteraction, ApplicationCommandInteractionData, + }, + message_component::{MessageComponentInteraction, MessageComponentInteractionData}, + Interaction, InteractionApplicationCommandCallbackDataFlags, InteractionResponseType, + MessageInteraction, }, Permissions, }, @@ -15,13 +18,12 @@ use serenity::{ use crate::{data::GuildOptionsKey, utils::message::embed_author}; pub(crate) async fn handle_interaction(ctx: &Context, interaction: &Interaction) -> CommandResult { - let data = interaction.data.as_ref().ok_or("Failed to get data")?; - - match data { - InteractionData::ApplicationCommand(app) => { - command(ctx, &interaction, &app).await?; + match interaction { + Interaction::ApplicationCommand(app) => { + command(ctx, &app, &app.data).await?; } - InteractionData::MessageComponent(msg) => message_interact(ctx, interaction, msg).await?, + Interaction::MessageComponent(msg) => message_interact(ctx, msg, &msg.data).await?, + _ => {} } Ok(()) @@ -29,7 +31,7 @@ pub(crate) async fn handle_interaction(ctx: &Context, interaction: &Interaction) async fn command( ctx: &Context, - interaction: &Interaction, + interaction: &ApplicationCommandInteraction, data: &ApplicationCommandInteractionData, ) -> CommandResult { let name = &data.name; @@ -76,7 +78,7 @@ async fn command( async fn goulag( ctx: &Context, - interaction: &Interaction, + interaction: &ApplicationCommandInteraction, data: &ApplicationCommandInteractionData, guild_id: u64, author: &Member, @@ -152,8 +154,8 @@ async fn goulag( async fn message_interact( ctx: &Context, - interaction: &Interaction, - msg_interaction: &MessageComponent, + interaction: &MessageComponentInteraction, + msg_interaction: &MessageComponentInteractionData, ) -> CommandResult { match msg_interaction.custom_id.as_str() { "gulag_button" => { diff --git a/src/commands/music/utils.rs b/src/commands/music/utils.rs index 9d72b9c..37bbfcd 100644 --- a/src/commands/music/utils.rs +++ b/src/commands/music/utils.rs @@ -6,7 +6,7 @@ use serenity::{ channel::{Message, ReactionType}, guild::{Member, PartialMember}, id::GuildId, - interactions::ButtonStyle, + interactions::message_component::ButtonStyle, Permissions, }, }; @@ -135,6 +135,7 @@ impl<'a> CreateMessageExt for CreateMessage<'a> { } fn add_music_buttons<'b>(&'b mut self) -> &'b mut Self { + return self; self.components(|comp| { comp.create_action_row(|row| { row.create_button(|but| { diff --git a/src/main.rs b/src/main.rs index 41b7167..10b921e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -224,11 +224,22 @@ impl EventHandler for Messages { } } + async fn channel_create(&self, _ctx: Context, channel: &GuildChannel) { + log::debug!("{:?}", channel); + } + async fn interaction_create(&self, ctx: Context, interaction: Interaction) { if let Err(e) = interaction::handle_interaction(&ctx, &interaction).await { error!("While handling interaction : {}", e); } } + + async fn thread_create(&self, ctx: Context, thread: GuildChannel) { + if let Err(e) = thread.id.join_thread(&ctx).await { + log::error!("Failed to join thread : {}", e); + } + } + } async fn log_mentions(ctx: Context, new_message: &Message) -> CommandResult {