From 5dc15211818c5ae46c2211ab7fccd73a932cc149 Mon Sep 17 00:00:00 2001 From: jellywx Date: Sun, 27 Jun 2021 12:52:25 +0100 Subject: [PATCH] set the permissions correctly on soundboard cmd --- src/cmds/play.rs | 7 ++++--- src/event_handlers.rs | 4 ++-- src/main.rs | 8 +++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cmds/play.rs b/src/cmds/play.rs index d3e6b37..55583cc 100644 --- a/src/cmds/play.rs +++ b/src/cmds/play.rs @@ -17,7 +17,7 @@ use crate::{ event_handlers::RestartTrack, framework::{Args, CommandInvoke, CreateGenericResponse}, guild_data::CtxGuildData, - join_channel, play_cmd, + join_channel, play_from_query, sound::Sound, AudioIndex, MySQL, }; @@ -48,7 +48,7 @@ pub async fn play( .respond( ctx.http.clone(), CreateGenericResponse::new() - .content(play_cmd(ctx, guild, invoke.author_id(), args, false).await), + .content(play_from_query(ctx, guild, invoke.author_id(), args, false).await), ) .await?; @@ -78,7 +78,7 @@ pub async fn loop_play( .respond( ctx.http.clone(), CreateGenericResponse::new() - .content(play_cmd(ctx, guild, invoke.author_id(), args, true).await), + .content(play_from_query(ctx, guild, invoke.author_id(), args, true).await), ) .await?; @@ -184,6 +184,7 @@ __Available ambience sounds:__ } #[command("soundboard")] +#[required_permissions(Managed)] #[group("Play")] #[kind(Slash)] #[description("Get a menu of sounds with buttons to play them")] diff --git a/src/event_handlers.rs b/src/event_handlers.rs index 6b3be41..7174750 100644 --- a/src/event_handlers.rs +++ b/src/event_handlers.rs @@ -1,7 +1,7 @@ use crate::{ framework::RegexFramework, guild_data::CtxGuildData, - join_channel, play_audio, play_cmd, + join_channel, play_audio, play_from_query, sound::{JoinSoundCtx, Sound}, MySQL, ReqwestClient, }; @@ -208,7 +208,7 @@ SELECT name, id, plays, public, server_id, uploader_id }; args.args.insert("query".to_string(), data.custom_id); - play_cmd( + play_from_query( &ctx, interaction.guild(ctx.cache.clone()).await.unwrap(), member.user.id, diff --git a/src/main.rs b/src/main.rs index 6b66413..99111d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -140,7 +140,13 @@ async fn join_channel( (call, res) } -async fn play_cmd(ctx: &Context, guild: Guild, user_id: UserId, args: Args, loop_: bool) -> String { +async fn play_from_query( + ctx: &Context, + guild: Guild, + user_id: UserId, + args: Args, + loop_: bool, +) -> String { let guild_id = guild.id; let channel_to_join = guild