UEEZR1/kDPa9

This commit is contained in:
Ashley Graves 2024-10-10 18:17:08 +02:00
parent 20e4772015
commit cf30d2e4b6

View file

@ -42,7 +42,11 @@ module.exports = {
await interaction.deferReply({ ephemeral: true });
const command = interaction.options.getSubcommand(true);
const tag = interaction.options.getString("tag").replaceAll(" ", "_");
const blacklist = ((await knex.select("blacklist").from("blacklists").where("user", interaction.user.id).first()).blacklist ?? "").split(" ");
var result = await knex.select("blacklist").from("blacklists").where("user", interaction.user.id).first();
if (!result)
result = { blacklist: '' };
const blacklist = (result.blacklist ?? "").trim().split(" ");
const data = {
user: interaction.user.id,
@ -76,15 +80,18 @@ module.exports = {
const value = interaction.options.getFocused() ?? "";
const command = interaction.options.getSubcommand(true);
if (command == "remove") {
const blacklist = ((await knex.select("blacklist").from("blacklists").where("user", interaction.user.id).first()) ?? { blacklist: '' }).blacklist.trim().split(" ");
var result = await knex.select("blacklist").from("blacklists").where("user", interaction.user.id).first();
if (!result)
result = { blacklist: '' };
const blacklist = (result.blacklist ?? "").trim().split(" ");
const choices = [];
for (const tag of blacklist) {
if (tag != "" && (value == "" || tag.startsWith(value.trim())))
if (value == "" || tag.startsWith(value.trim()))
choices.push(tag);
}
if (choices.length == 0)
return;
console.log(choices);
await interaction.respond(choices.map(choice => ({ name: choice, value: choice })))
}