Skip to content

Commit 2d5e5b8

Browse files
authored
Merge pull request #6 from f-code-club/fix/permission
fix: only moderator allow to add and delete
2 parents d02cce6 + 00f555f commit 2d5e5b8

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/command/add.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ use crate::{Context, Message, database, util};
55

66
/// Add one or more candidate IDs to the candidates database from a text file.
77
#[tracing::instrument]
8-
#[poise::command(slash_command, prefix_command, ephemeral)]
8+
#[poise::command(
9+
slash_command,
10+
prefix_command,
11+
ephemeral,
12+
required_permissions = "MANAGE_MESSAGES | MANAGE_THREADS"
13+
)]
914
pub async fn add(
1015
ctx: Context<'_>,
1116
#[description = "Text file with candidate IDs (one per line, UTF‑8)"] id: serenity::Attachment,

src/command/delete.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ use crate::{Context, Message, database, util};
44

55
/// Delete a candidate by ID from the candidates database.
66
#[tracing::instrument]
7-
#[poise::command(slash_command, prefix_command, ephemeral)]
8-
pub async fn delete(
9-
ctx: Context<'_>,
10-
#[description = "Candidate ID to delete"] id: String,
11-
) -> Result<()> {
7+
#[poise::command(
8+
slash_command,
9+
prefix_command,
10+
ephemeral,
11+
required_permissions = "MANAGE_MESSAGES | MANAGE_THREADS"
12+
)]
13+
pub async fn delete(ctx: Context<'_>, id: String) -> Result<()> {
1214
let pool = &ctx.data().pool;
1315

1416
if !util::is_valid_id(&id) {

0 commit comments

Comments
 (0)