0ckCCZYC2tT9
This commit is contained in:
parent
d5d7f41f2a
commit
e5ba09e315
2 changed files with 12 additions and 4 deletions
|
@ -26,6 +26,11 @@ const data = new SlashCommandBuilder()
|
|||
.setDescription("Tag to unblacklist")
|
||||
.setAutocomplete(true)
|
||||
))
|
||||
.addSubcommand((builder) =>
|
||||
builder //
|
||||
.setName("list")
|
||||
.setDescription("List current blacklist")
|
||||
)
|
||||
.setContexts([
|
||||
InteractionContextType.Guild,
|
||||
InteractionContextType.BotDM,
|
||||
|
@ -41,7 +46,6 @@ module.exports = {
|
|||
async execute(interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const command = interaction.options.getSubcommand(true);
|
||||
const tag = interaction.options.getString("tag").replaceAll(" ", "_");
|
||||
var result = await knex.select("blacklist").from("blacklists").where("user", interaction.user.id).first();
|
||||
if (!result)
|
||||
result = { blacklist: '' };
|
||||
|
@ -50,10 +54,13 @@ module.exports = {
|
|||
|
||||
const data = {
|
||||
user: interaction.user.id,
|
||||
blacklist: [...blacklist].join(" ").trim()
|
||||
blacklist: blacklist.join(" ").trim()
|
||||
}
|
||||
|
||||
switch (command) {
|
||||
case "add" || "remove":
|
||||
const tag = interaction.options.getString("tag").replaceAll(" ", "_");
|
||||
|
||||
case "add":
|
||||
if (blacklist.includes(tag)) {
|
||||
await interaction.followUp("This tag is already blacklisted.");
|
||||
|
@ -67,6 +74,9 @@ module.exports = {
|
|||
data.blacklist = data.blacklist.split(" ").filter(i => i != tag).join(" ").trim();
|
||||
await interaction.followUp("Successfully removed!");
|
||||
break;
|
||||
case "list":
|
||||
await interaction.followUp(`Current blacklist:\n\`\`${blacklist.join(", ").replaceAll("`", "`" + String.fromCharCode(8203))}\`\``);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -137,11 +137,9 @@ module.exports = {
|
|||
const tags = (interaction.options.getString("tags") ?? "").split(" ");
|
||||
const booru = interaction.options.getString("booru") ?? defaultBooru;
|
||||
const rating = (interaction.options.getString("rating") ?? ratings[0]);
|
||||
console.log(rating);
|
||||
|
||||
const userBlacklist = ((await knex.select("blacklist").from("blacklists").where("user", interaction.user.id).first()).blacklist ?? "").split(" ");
|
||||
const searchTags = [rating, ...tags, ...[...blacklist, ...userBlacklist].map(i => "-" + i)];
|
||||
console.log(rating, searchTags);
|
||||
|
||||
const startTime = process.hrtime.bigint();
|
||||
|
||||
|
|
Loading…
Reference in a new issue