added mention blocker to everything

This commit is contained in:
jellywx 2021-11-15 07:51:38 +00:00
parent ebd1efa990
commit 610779a293
2 changed files with 37 additions and 21 deletions

View File

@ -8,6 +8,7 @@ use crate::{
},
consts::{EMBED_DESCRIPTION_MAX_LENGTH, SELECT_MAX_ENTRIES, THEME_COLOR},
framework::{CommandInvoke, CommandOptions, CreateGenericResponse},
hooks::CHECK_GUILD_PERMISSIONS_HOOK,
SQLPool,
};
@ -49,6 +50,7 @@ use crate::{
)]
#[subcommand("view")]
#[description("View and remove from your personal todo list")]
#[hook(CHECK_GUILD_PERMISSIONS_HOOK)]
async fn todo(ctx: &Context, invoke: &mut CommandInvoke, args: CommandOptions) {
if invoke.guild_id().is_none() && args.subcommand_group != Some("user".to_string()) {
let _ = invoke
@ -106,7 +108,7 @@ WHERE users.user <=> ? AND channels.channel <=> ? AND guilds.guild <=> ?",
let resp = show_todo_page(&values, 0, keys.0, keys.1, keys.2);
let _ = invoke.respond(&ctx, resp).await;
invoke.respond(&ctx, resp).await.unwrap();
}
}
}
@ -193,6 +195,14 @@ pub fn show_todo_page(
"Server"
};
if todo_ids.is_empty() {
CreateGenericResponse::new().embed(|e| {
e.title(format!("{} Todo List", title))
.description("Todo List Empty!")
.footer(|f| f.text(format!("Page {} of {}", page + 1, pages)))
.color(*THEME_COLOR)
})
} else {
let todo_selector =
ComponentDataModel::TodoSelector(TodoSelector { page, user_id, channel_id, guild_id });
@ -209,7 +219,8 @@ pub fn show_todo_page(
comp.create_action_row(|row| {
row.create_select_menu(|menu| {
menu.custom_id(todo_selector.to_custom_id()).options(|opt| {
for (count, (id, disp)) in todo_ids.iter().zip(&display_vec).enumerate() {
for (count, (id, disp)) in todo_ids.iter().zip(&display_vec).enumerate()
{
opt.create_option(|o| {
o.label(format!("Mark {} complete", count + first_num))
.value(id)
@ -222,4 +233,5 @@ pub fn show_todo_page(
})
})
})
}
}

View File

@ -162,6 +162,7 @@ impl CommandInvoke {
InvokeModel::Slash(i) => {
if self.already_responded {
i.create_followup_message(http, |d| {
d.allowed_mentions(|m| m.empty_parse());
d.content(generic_response.content);
if let Some(embed) = generic_response.embed {
@ -181,6 +182,7 @@ impl CommandInvoke {
.map(|_| ())
} else if self.deferred {
i.edit_original_interaction_response(http, |d| {
d.allowed_mentions(|m| m.empty_parse());
d.content(generic_response.content);
if let Some(embed) = generic_response.embed {
@ -202,6 +204,7 @@ impl CommandInvoke {
i.create_interaction_response(http, |r| {
r.kind(InteractionResponseType::ChannelMessageWithSource)
.interaction_response_data(|d| {
d.allowed_mentions(|m| m.empty_parse());
d.content(generic_response.content);
if let Some(embed) = generic_response.embed {
@ -225,6 +228,7 @@ impl CommandInvoke {
InvokeModel::Component(i) => i
.create_interaction_response(http, |r| {
r.kind(InteractionResponseType::UpdateMessage).interaction_response_data(|d| {
d.allowed_mentions(|m| m.empty_parse());
d.content(generic_response.content);
if let Some(embed) = generic_response.embed {