Add support for masks
This commit is contained in:
@@ -3,7 +3,7 @@ use scc::HashSet;
|
||||
use twilight_model::id::Id;
|
||||
|
||||
use crate::{
|
||||
database::models::{Call, Channel},
|
||||
database::models::{Call, Channel, Participant},
|
||||
discord::sanitizing::SanitizeDiscordMarkdown,
|
||||
extras::Extras,
|
||||
framework::commands::{
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
permissions::Permission,
|
||||
},
|
||||
groups::calls::{
|
||||
get_display_profile,
|
||||
masks::{get_mask_display_name, get_mask_emoji},
|
||||
permissions::{NonNewAccountPermission, NotBannedPermission},
|
||||
strings::{
|
||||
get_string_call_answered, get_string_call_hangup_other_party,
|
||||
@@ -414,7 +414,20 @@ impl Command<State, Extras> for FriendRequestCommand {
|
||||
|
||||
let other_channel_id = call.other_party_channel_id(channel.id);
|
||||
|
||||
let profile = get_display_profile(ctx.event);
|
||||
let Some(participant) = Participant::get_for_user_and_channel_in_call(
|
||||
ctx.event.author.id.get(),
|
||||
ctx.event.channel_id.get(),
|
||||
call.id,
|
||||
&ctx.rt.state.db,
|
||||
)
|
||||
.await?
|
||||
else {
|
||||
ctx.send()
|
||||
.content("❌ You haven't even said hi! Who are you trying to add?")
|
||||
.await?;
|
||||
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
ctx
|
||||
.rt
|
||||
@@ -425,7 +438,7 @@ impl Command<State, Extras> for FriendRequestCommand {
|
||||
.content(
|
||||
&format!(
|
||||
"📬 **{}** wants you to send them a friend request on Discord! Their username is `{}`.",
|
||||
profile.name.sanitize(false),
|
||||
participant.display_name().sanitize(false),
|
||||
ctx.event.author.name.sanitize(false)
|
||||
)
|
||||
)
|
||||
@@ -505,21 +518,50 @@ impl Command<State, Extras> for MaskCommand {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
log::trace!("User is masked, checking for call...");
|
||||
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" },
|
||||
log::trace!("Found call ID: {call_id}");
|
||||
if let Some(mut participant) = Participant::get_for_user_and_channel_in_call(
|
||||
ctx.extras.user.id,
|
||||
ctx.event.channel_id.get(),
|
||||
call_id,
|
||||
&ctx.rt.state.db,
|
||||
)
|
||||
.await?
|
||||
{
|
||||
log::trace!(
|
||||
"Participant's is_masked is being set to {}",
|
||||
ctx.extras.user.is_masked
|
||||
);
|
||||
|
||||
participant.is_masked = ctx.extras.user.is_masked;
|
||||
participant.upsert(&ctx.rt.state.db).await?;
|
||||
|
||||
if ctx.extras.user.is_masked {
|
||||
ctx.send().content(format!("🎭 Your mask was set to on. You're currently being displayed as **{} {}**. You can toggle your mask on or off using `{}mask on` and `{}mask off`.",
|
||||
get_mask_emoji(&participant.user_mask).expect("User's mask did not exist"),
|
||||
get_mask_display_name(&participant.user_mask),
|
||||
ctx.prefix,
|
||||
ctx.prefix
|
||||
)
|
||||
)
|
||||
.await?;
|
||||
)).await?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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