Add remaining commands

This commit is contained in:
jude
2024-02-18 14:32:58 +00:00
parent 76a286076b
commit d8f266852a
25 changed files with 655 additions and 367 deletions

View File

@ -1,5 +1,5 @@
pub mod set_allowed_dm;
pub mod unset_allowed_dm;
pub mod set;
pub mod unset;
use crate::{Context, Error};

View File

@ -0,0 +1,38 @@
use poise::{serenity_prelude::CreateEmbed, CreateReply};
use serde::{Deserialize, Serialize};
use crate::{
consts::THEME_COLOR,
models::CtxData,
utils::{Extract, Recordable},
Context, Error,
};
#[derive(Serialize, Deserialize, Extract)]
pub struct Options;
impl Recordable for Options {
async fn run(self, ctx: Context<'_>) -> Result<(), Error> {
let mut user_data = ctx.author_data().await?;
user_data.allowed_dm = true;
user_data.commit_changes(&ctx.data().database).await;
ctx.send(
CreateReply::default().ephemeral(true).embed(
CreateEmbed::new()
.title("DMs permitted")
.description("You will receive a message if a user sets a DM reminder for you.")
.color(*THEME_COLOR),
),
)
.await?;
Ok(())
}
}
/// Allow other users to set reminders in your direct messages
#[poise::command(slash_command, rename = "allow", identifying_name = "set_allowed_dm")]
pub async fn set(ctx: Context<'_>) -> Result<(), Error> {
(Options {}).run(ctx).await
}

View File

@ -1,23 +0,0 @@
use poise::{serenity_prelude::CreateEmbed, CreateReply};
use crate::{consts::THEME_COLOR, models::CtxData, Context, Error};
/// Allow other users to set reminders in your direct messages
#[poise::command(slash_command, rename = "allow", identifying_name = "set_allowed_dm")]
pub async fn set_allowed_dm(ctx: Context<'_>) -> Result<(), Error> {
let mut user_data = ctx.author_data().await?;
user_data.allowed_dm = true;
user_data.commit_changes(&ctx.data().database).await;
ctx.send(
CreateReply::default().ephemeral(true).embed(
CreateEmbed::new()
.title("DMs permitted")
.description("You will receive a message if a user sets a DM reminder for you.")
.color(*THEME_COLOR),
),
)
.await?;
Ok(())
}

View File

@ -0,0 +1,41 @@
use poise::{serenity_prelude::CreateEmbed, CreateReply};
use serde::{Deserialize, Serialize};
use crate::{
consts::THEME_COLOR,
models::CtxData,
utils::{Extract, Recordable},
Context, Error,
};
#[derive(Serialize, Deserialize, Extract)]
pub struct Options;
impl Recordable for Options {
async fn run(self, ctx: Context<'_>) -> Result<(), Error> {
let mut user_data = ctx.author_data().await?;
user_data.allowed_dm = false;
user_data.commit_changes(&ctx.data().database).await;
ctx.send(
CreateReply::default().ephemeral(true).embed(
CreateEmbed::new()
.title("DMs blocked")
.description(concat!(
"You can still set DM reminders for yourself or for users with",
" DMs enabled."
))
.color(*THEME_COLOR),
),
)
.await?;
Ok(())
}
}
/// Block other users from setting reminders in your direct messages
#[poise::command(slash_command, rename = "block", identifying_name = "unset_allowed_dm")]
pub async fn unset(ctx: Context<'_>) -> Result<(), Error> {
(Options {}).run(ctx).await
}

View File

@ -1,25 +0,0 @@
use poise::{serenity_prelude::CreateEmbed, CreateReply};
use crate::{consts::THEME_COLOR, models::CtxData, Context, Error};
/// Block other users from setting reminders in your direct messages
#[poise::command(slash_command, rename = "block", identifying_name = "unset_allowed_dm")]
pub async fn unset_allowed_dm(ctx: Context<'_>) -> Result<(), Error> {
let mut user_data = ctx.author_data().await?;
user_data.allowed_dm = false;
user_data.commit_changes(&ctx.data().database).await;
ctx.send(
CreateReply::default().ephemeral(true).embed(
CreateEmbed::new()
.title("DMs blocked")
.description(
"You can still set DM reminders for yourself or for users with DMs enabled.",
)
.color(*THEME_COLOR),
),
)
.await?;
Ok(())
}