Start working on mask command

This commit is contained in:
2025-08-23 12:16:06 -03:00
parent b10484cacc
commit 7d47a9eb35
4 changed files with 98 additions and 7 deletions
@@ -0,0 +1,6 @@
ALTER TABLE payphone.participants ADD is_masked BOOLEAN;
CREATE MATERIALIZED VIEW IF NOT EXISTS payphone.participants_by_user_id AS
SELECT user_id, call_id, channel_id FROM payphone.participants
WHERE user_id IS NOT NULL AND call_id IS NOT NULL AND channel_id IS NOT NULL
PRIMARY KEY (user_id, call_id);
+90 -5
View File
@@ -7,7 +7,10 @@ use crate::{
discord::sanitizing::SanitizeDiscordMarkdown,
extras::Extras,
framework::commands::{
Command, CommandError, context::CommandContext, permissions::Permission,
Command, CommandError,
arguments::{Arg, ParseArguments},
context::CommandContext,
permissions::Permission,
},
groups::calls::{
get_display_profile,
@@ -224,10 +227,7 @@ impl Command<State, Extras> for SkipCommand {
ctx.rt
.http
.create_message(Id::new(call.other_party_channel_id(channel.id)))
.content(&format!(
"☎️ {}",
get_string_call_hangup_other_party(ctx.prefix)
))
.content(&format!("☎️ {}", get_string_call_answered(ctx.prefix)))
.await
.bye();
} else {
@@ -427,3 +427,88 @@ impl Command<State, Extras> for FriendRequestCommand {
Ok(())
}
}
#[derive(Debug)]
pub struct MaskCommand;
#[async_trait]
impl Command<State, Extras> for MaskCommand {
fn name(&self) -> &'static str {
"mask"
}
fn aliases(&self) -> &'static [&'static str] {
&["m"]
}
fn description(&self) -> &'static str {
"Masks your profile from the other party and updates your preferences for future calls."
}
async fn execute(
&self,
mut ctx: CommandContext<'_, State, Extras>,
args: &str,
) -> Result<(), CommandError> {
let Arg(toggle) = match Arg::<Option<bool>>::parse(args, &ctx).await {
Ok(v) => v,
Err(_) => {
ctx
.send()
.content(
format!(
"❓ Are you sure that's correct? Use `{}mask on` and `{}mask off`, or just `{}mask` to toggle it.",
ctx.prefix, ctx.prefix, ctx.prefix
)
)
.await?;
return Ok(());
}
};
if let Some(toggle) = toggle {
ctx.extras.user.is_masked = toggle;
} else {
ctx.extras.user.is_masked = !ctx.extras.user.is_masked;
}
ctx.extras.user.insert(&ctx.rt.state.db).await?;
let Some(channel) =
Channel::get_by_id(ctx.event.channel_id.get(), &ctx.rt.state.db).await?
else {
ctx
.send()
.content(
format!(
"🎭 Your mask was set to `{}`. You can toggle your mask on or off using `{}mask on` and `{}mask off`.",
if ctx.extras.user.is_masked { "on" } else { "off" },
ctx.prefix,
ctx.prefix
)
)
.await?;
return Ok(());
};
if let Some(call_id) = channel.call_id {
} else {
ctx
.send()
.content(
format!(
"🎭 Your mask was set to `{}`. You can toggle your mask on or off using `{}mask on` and `{}mask off`.",
if ctx.extras.user.is_masked { "on" } else { "off" },
ctx.prefix,
ctx.prefix
)
)
.await?;
}
Ok(())
}
}