diff --git a/src/framework/commands/mod.rs b/src/framework/commands/mod.rs index 051a22e..6c43147 100644 --- a/src/framework/commands/mod.rs +++ b/src/framework/commands/mod.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use async_trait::async_trait; use thiserror::Error; -use crate::framework::commands::{arguments::Argument, context::CommandContext}; +use crate::framework::commands::{arguments::Argument, context::CommandContext, permissions::Permission}; pub mod arguments; pub mod context; @@ -38,8 +38,8 @@ pub trait Command: Send + Sync + Debug { fn arguments(&self) -> &'static [Argument] { &[] } - fn permissions(&self) -> &'static [Box + Send + Sync>] { - &[] + fn permissions(&self) -> Vec + Send + Sync + 'static>> { + vec![] } /// Returns the command name + all its aliases. diff --git a/src/framework/commands/runner.rs b/src/framework/commands/runner.rs index 65c4b48..dd6ae2f 100644 --- a/src/framework/commands/runner.rs +++ b/src/framework/commands/runner.rs @@ -39,9 +39,7 @@ impl OnMessageHandler for CommandRunner { .await .inspect_err(|e| log::error!("Permission check failed: {e}"))? { - return Err( - format!("The check for permission {permission:?} failed").into() - ); + return Ok(()); } } diff --git a/src/groups/calls/commands.rs b/src/groups/calls/commands.rs index 85d1643..ccb77fb 100644 --- a/src/groups/calls/commands.rs +++ b/src/groups/calls/commands.rs @@ -5,8 +5,10 @@ use twilight_model::id::Id; use crate::{ database::models::{Call, Channel}, discord::sanitizing::SanitizeDiscordMarkdown, - framework::commands::{Command, CommandError, context::CommandContext}, - groups::calls::get_display_profile, + framework::commands::{ + Command, CommandError, context::CommandContext, permissions::Permission, + }, + groups::calls::{get_display_profile, permissions::NotBannedPermission}, state::State, utils::Bye, }; @@ -38,6 +40,10 @@ impl Command for CallCommand { &["c"] } + fn permissions(&self) -> Vec + Send + Sync + 'static>> { + vec![Box::new(NotBannedPermission)] + } + async fn execute( &self, ctx: CommandContext<'_, State>, @@ -124,6 +130,10 @@ impl Command for SkipCommand { &["s", "next"] } + fn permissions(&self) -> Vec + Send + Sync + 'static>> { + vec![Box::new(NotBannedPermission)] + } + async fn execute( &self, ctx: CommandContext<'_, State>, @@ -226,6 +236,10 @@ impl Command for HangupCommand { &["h", "hang"] } + fn permissions(&self) -> Vec + Send + Sync + 'static>> { + vec![Box::new(NotBannedPermission)] + } + async fn execute( &self, ctx: CommandContext<'_, State>, @@ -324,6 +338,10 @@ impl Command for FriendRequestCommand { "Shows your username to the other party and asks them to send you a friend request on Discord." } + fn permissions(&self) -> Vec + Send + Sync + 'static>> { + vec![Box::new(NotBannedPermission)] + } + async fn execute( &self, ctx: CommandContext<'_, State>,