diff options
Diffstat (limited to 'src/commands/cron.rs')
| -rw-r--r-- | src/commands/cron.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/commands/cron.rs b/src/commands/cron.rs index ec5b702..809d1a4 100644 --- a/src/commands/cron.rs +++ b/src/commands/cron.rs | |||
| @@ -12,7 +12,6 @@ type Context<'a> = poise::Context<'a, Data, Error>; | |||
| 12 | #[poise::command( | 12 | #[poise::command( |
| 13 | slash_command, | 13 | slash_command, |
| 14 | guild_only, | 14 | guild_only, |
| 15 | required_permissions = "MANAGE_GUILD", | ||
| 16 | subcommands("dodaj_audio", "dodaj_wiadomość", "pokaż", "usuń", "pauza", "wznów",) | 15 | subcommands("dodaj_audio", "dodaj_wiadomość", "pokaż", "usuń", "pauza", "wznów",) |
| 17 | )] | 16 | )] |
| 18 | pub async fn cron(_ctx: Context<'_>) -> Result<()> { | 17 | pub async fn cron(_ctx: Context<'_>) -> Result<()> { |
| @@ -20,7 +19,7 @@ pub async fn cron(_ctx: Context<'_>) -> Result<()> { | |||
| 20 | } | 19 | } |
| 21 | 20 | ||
| 22 | /// Schedule audio playback | 21 | /// Schedule audio playback |
| 23 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] | 22 | #[poise::command(slash_command, guild_only)] |
| 24 | pub async fn dodaj_audio( | 23 | pub async fn dodaj_audio( |
| 25 | ctx: Context<'_>, | 24 | ctx: Context<'_>, |
| 26 | #[description = "Cron expression (e.g. \"37 21 * * *\" = every day at 21:37)"] cron_expression: String, | 25 | #[description = "Cron expression (e.g. \"37 21 * * *\" = every day at 21:37)"] cron_expression: String, |
| @@ -75,7 +74,7 @@ pub async fn dodaj_audio( | |||
| 75 | } | 74 | } |
| 76 | 75 | ||
| 77 | /// Schedule a periodic message | 76 | /// Schedule a periodic message |
| 78 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] | 77 | #[poise::command(slash_command, guild_only)] |
| 79 | pub async fn dodaj_wiadomość( | 78 | pub async fn dodaj_wiadomość( |
| 80 | ctx: Context<'_>, | 79 | ctx: Context<'_>, |
| 81 | #[description = "Cron expression (e.g. \"37 21 * * *\" = every day at 21:37)"] cron_expression: String, | 80 | #[description = "Cron expression (e.g. \"37 21 * * *\" = every day at 21:37)"] cron_expression: String, |
| @@ -109,7 +108,7 @@ pub async fn dodaj_wiadomość( | |||
| 109 | } | 108 | } |
| 110 | 109 | ||
| 111 | /// List all cron jobs | 110 | /// List all cron jobs |
| 112 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] | 111 | #[poise::command(slash_command, guild_only)] |
| 113 | pub async fn pokaż(ctx: Context<'_>) -> Result<()> { | 112 | pub async fn pokaż(ctx: Context<'_>) -> Result<()> { |
| 114 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; | 113 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; |
| 115 | let jobs = database::list_cron_jobs(&ctx.data().db_pool, guild_id.get() as i64).await?; | 114 | let jobs = database::list_cron_jobs(&ctx.data().db_pool, guild_id.get() as i64).await?; |
| @@ -144,7 +143,7 @@ pub async fn pokaż(ctx: Context<'_>) -> Result<()> { | |||
| 144 | } | 143 | } |
| 145 | 144 | ||
| 146 | /// Remove a cron job | 145 | /// Remove a cron job |
| 147 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] | 146 | #[poise::command(slash_command, guild_only)] |
| 148 | pub async fn usuń( | 147 | pub async fn usuń( |
| 149 | ctx: Context<'_>, | 148 | ctx: Context<'_>, |
| 150 | #[description = "ID pracy do usunięcia"] job_id: i64, | 149 | #[description = "ID pracy do usunięcia"] job_id: i64, |
| @@ -159,13 +158,15 @@ pub async fn usuń( | |||
| 159 | } | 158 | } |
| 160 | 159 | ||
| 161 | /// Pause a cron job | 160 | /// Pause a cron job |
| 162 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] | 161 | #[poise::command(slash_command, guild_only)] |
| 163 | pub async fn pauza( | 162 | pub async fn pauza( |
| 164 | ctx: Context<'_>, | 163 | ctx: Context<'_>, |
| 165 | #[description = "ID pracy do zapauzowania"] job_id: i64, | 164 | #[description = "ID pracy do zapauzowania"] job_id: i64, |
| 166 | ) -> Result<()> { | 165 | ) -> Result<()> { |
| 167 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; | 166 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; |
| 168 | if database::set_cron_job_active(&ctx.data().db_pool, job_id, guild_id.get() as i64, false).await? { | 167 | if database::set_cron_job_active(&ctx.data().db_pool, job_id, guild_id.get() as i64, false) |
| 168 | .await? | ||
| 169 | { | ||
| 169 | ctx.say(lang::fmt_cron_paused(job_id)).await?; | 170 | ctx.say(lang::fmt_cron_paused(job_id)).await?; |
| 170 | } else { | 171 | } else { |
| 171 | ctx.say(lang::fmt_cron_not_found(job_id)).await?; | 172 | ctx.say(lang::fmt_cron_not_found(job_id)).await?; |
| @@ -174,13 +175,15 @@ pub async fn pauza( | |||
| 174 | } | 175 | } |
| 175 | 176 | ||
| 176 | /// Resume a paused cron job | 177 | /// Resume a paused cron job |
| 177 | #[poise::command(slash_command, guild_only, required_permissions = "MANAGE_GUILD")] | 178 | #[poise::command(slash_command, guild_only)] |
| 178 | pub async fn wznów( | 179 | pub async fn wznów( |
| 179 | ctx: Context<'_>, | 180 | ctx: Context<'_>, |
| 180 | #[description = "ID pracy cron do wznowienia"] job_id: i64, | 181 | #[description = "ID pracy cron do wznowienia"] job_id: i64, |
| 181 | ) -> Result<()> { | 182 | ) -> Result<()> { |
| 182 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; | 183 | let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; |
| 183 | if database::set_cron_job_active(&ctx.data().db_pool, job_id, guild_id.get() as i64, true).await? { | 184 | if database::set_cron_job_active(&ctx.data().db_pool, job_id, guild_id.get() as i64, true) |
| 185 | .await? | ||
| 186 | { | ||
| 184 | ctx.say(lang::fmt_cron_resumed(job_id)).await?; | 187 | ctx.say(lang::fmt_cron_resumed(job_id)).await?; |
| 185 | } else { | 188 | } else { |
| 186 | ctx.say(lang::fmt_cron_not_found(job_id)).await?; | 189 | ctx.say(lang::fmt_cron_not_found(job_id)).await?; |
