set the permissions correctly on soundboard cmd

This commit is contained in:
jellywx 2021-06-27 12:52:25 +01:00
parent a38e4c808e
commit 5dc1521181
3 changed files with 13 additions and 6 deletions

View File

@ -17,7 +17,7 @@ use crate::{
event_handlers::RestartTrack, event_handlers::RestartTrack,
framework::{Args, CommandInvoke, CreateGenericResponse}, framework::{Args, CommandInvoke, CreateGenericResponse},
guild_data::CtxGuildData, guild_data::CtxGuildData,
join_channel, play_cmd, join_channel, play_from_query,
sound::Sound, sound::Sound,
AudioIndex, MySQL, AudioIndex, MySQL,
}; };
@ -48,7 +48,7 @@ pub async fn play(
.respond( .respond(
ctx.http.clone(), ctx.http.clone(),
CreateGenericResponse::new() 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?; .await?;
@ -78,7 +78,7 @@ pub async fn loop_play(
.respond( .respond(
ctx.http.clone(), ctx.http.clone(),
CreateGenericResponse::new() 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?; .await?;
@ -184,6 +184,7 @@ __Available ambience sounds:__
} }
#[command("soundboard")] #[command("soundboard")]
#[required_permissions(Managed)]
#[group("Play")] #[group("Play")]
#[kind(Slash)] #[kind(Slash)]
#[description("Get a menu of sounds with buttons to play them")] #[description("Get a menu of sounds with buttons to play them")]

View File

@ -1,7 +1,7 @@
use crate::{ use crate::{
framework::RegexFramework, framework::RegexFramework,
guild_data::CtxGuildData, guild_data::CtxGuildData,
join_channel, play_audio, play_cmd, join_channel, play_audio, play_from_query,
sound::{JoinSoundCtx, Sound}, sound::{JoinSoundCtx, Sound},
MySQL, ReqwestClient, MySQL, ReqwestClient,
}; };
@ -208,7 +208,7 @@ SELECT name, id, plays, public, server_id, uploader_id
}; };
args.args.insert("query".to_string(), data.custom_id); args.args.insert("query".to_string(), data.custom_id);
play_cmd( play_from_query(
&ctx, &ctx,
interaction.guild(ctx.cache.clone()).await.unwrap(), interaction.guild(ctx.cache.clone()).await.unwrap(),
member.user.id, member.user.id,

View File

@ -140,7 +140,13 @@ async fn join_channel(
(call, res) (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 guild_id = guild.id;
let channel_to_join = guild let channel_to_join = guild