diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 01:08:08 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 01:08:08 +0100 |
| commit | 8e6fced543735aa4c68e70221518a37c36780d59 (patch) | |
| tree | 7b7e6be03c3091caf2ae7bed12b40b6d6f1e71e5 /src/commands/cron.rs | |
| parent | utilities: sanitize filenames and isolate temp operations (diff) | |
| download | senator-sperma-8e6fced543735aa4c68e70221518a37c36780d59.tar.gz senator-sperma-8e6fced543735aa4c68e70221518a37c36780d59.zip | |
commands: gate admin, trigger, cron and recording behind permissions
Diffstat (limited to 'src/commands/cron.rs')
| -rw-r--r-- | src/commands/cron.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/commands/cron.rs b/src/commands/cron.rs index a645581..47c3d62 100644 --- a/src/commands/cron.rs +++ b/src/commands/cron.rs | |||
| @@ -11,6 +11,8 @@ type Context<'a> = poise::Context<'a, Data, Error>; | |||
| 11 | /// Cron job management | 11 | /// Cron job management |
| 12 | #[poise::command( | 12 | #[poise::command( |
| 13 | slash_command, | 13 | slash_command, |
| 14 | guild_only, | ||
| 15 | required_permissions = "MANAGE_GUILD", | ||
| 14 | subcommands("dodaj_audio", "dodaj_wiadomość", "pokaż", "usuń", "pauza", "wznów",) | 16 | subcommands("dodaj_audio", "dodaj_wiadomość", "pokaż", "usuń", "pauza", "wznów",) |
| 15 | )] | 17 | )] |
| 16 | pub async fn cron(_ctx: Context<'_>) -> Result<()> { | 18 | pub async fn cron(_ctx: Context<'_>) -> Result<()> { |
| @@ -18,7 +20,7 @@ pub async fn cron(_ctx: Context<'_>) -> Result<()> { | |||
| 18 | } | 20 | } |
| 19 | 21 | ||
| 20 | /// Schedule audio playback | 22 | /// Schedule audio playback |
| 21 | #[poise::command(slash_command)] | 23 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] |
| 22 | pub async fn dodaj_audio( | 24 | pub async fn dodaj_audio( |
| 23 | ctx: Context<'_>, | 25 | ctx: Context<'_>, |
| 24 | #[description = "Cron expression (e.g. \"37 21 * * *\" = every day at 21:37)"] cron_expression: String, | 26 | #[description = "Cron expression (e.g. \"37 21 * * *\" = every day at 21:37)"] cron_expression: String, |
| @@ -58,7 +60,7 @@ pub async fn dodaj_audio( | |||
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | /// Schedule a periodic message | 62 | /// Schedule a periodic message |
| 61 | #[poise::command(slash_command)] | 63 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] |
| 62 | pub async fn dodaj_wiadomość( | 64 | pub async fn dodaj_wiadomość( |
| 63 | ctx: Context<'_>, | 65 | ctx: Context<'_>, |
| 64 | #[description = "Cron expression (e.g. \"37 21 * * *\" = every day at 21:37)"] cron_expression: String, | 66 | #[description = "Cron expression (e.g. \"37 21 * * *\" = every day at 21:37)"] cron_expression: String, |
| @@ -85,7 +87,7 @@ pub async fn dodaj_wiadomość( | |||
| 85 | } | 87 | } |
| 86 | 88 | ||
| 87 | /// List all cron jobs | 89 | /// List all cron jobs |
| 88 | #[poise::command(slash_command)] | 90 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] |
| 89 | pub async fn pokaż(ctx: Context<'_>) -> Result<()> { | 91 | pub async fn pokaż(ctx: Context<'_>) -> Result<()> { |
| 90 | let jobs = database::list_cron_jobs(&ctx.data().db_pool).await?; | 92 | let jobs = database::list_cron_jobs(&ctx.data().db_pool).await?; |
| 91 | if jobs.is_empty() { | 93 | if jobs.is_empty() { |
| @@ -119,7 +121,7 @@ pub async fn pokaż(ctx: Context<'_>) -> Result<()> { | |||
| 119 | } | 121 | } |
| 120 | 122 | ||
| 121 | /// Remove a cron job | 123 | /// Remove a cron job |
| 122 | #[poise::command(slash_command)] | 124 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] |
| 123 | pub async fn usuń( | 125 | pub async fn usuń( |
| 124 | ctx: Context<'_>, | 126 | ctx: Context<'_>, |
| 125 | #[description = "ID pracy do usunięcia"] job_id: i64, | 127 | #[description = "ID pracy do usunięcia"] job_id: i64, |
| @@ -133,7 +135,7 @@ pub async fn usuń( | |||
| 133 | } | 135 | } |
| 134 | 136 | ||
| 135 | /// Pause a cron job | 137 | /// Pause a cron job |
| 136 | #[poise::command(slash_command)] | 138 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] |
| 137 | pub async fn pauza( | 139 | pub async fn pauza( |
| 138 | ctx: Context<'_>, | 140 | ctx: Context<'_>, |
| 139 | #[description = "ID pracy do zapauzowania"] job_id: i64, | 141 | #[description = "ID pracy do zapauzowania"] job_id: i64, |
| @@ -147,7 +149,7 @@ pub async fn pauza( | |||
| 147 | } | 149 | } |
| 148 | 150 | ||
| 149 | /// Resume a paused cron job | 151 | /// Resume a paused cron job |
| 150 | #[poise::command(slash_command)] | 152 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] |
| 151 | pub async fn wznów( | 153 | pub async fn wznów( |
| 152 | ctx: Context<'_>, | 154 | ctx: Context<'_>, |
| 153 | #[description = "ID pracy cron do wznowienia"] job_id: i64, | 155 | #[description = "ID pracy cron do wznowienia"] job_id: i64, |
