Start working on mask command
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user