UEEZR1/kDPa9
This commit is contained in:
parent
20e4772015
commit
cf30d2e4b6
1 changed files with 12 additions and 5 deletions
|
@ -42,7 +42,11 @@ module.exports = {
|
||||||
await interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
const command = interaction.options.getSubcommand(true);
|
const command = interaction.options.getSubcommand(true);
|
||||||
const tag = interaction.options.getString("tag").replaceAll(" ", "_");
|
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 = {
|
const data = {
|
||||||
user: interaction.user.id,
|
user: interaction.user.id,
|
||||||
|
@ -76,15 +80,18 @@ module.exports = {
|
||||||
const value = interaction.options.getFocused() ?? "";
|
const value = interaction.options.getFocused() ?? "";
|
||||||
const command = interaction.options.getSubcommand(true);
|
const command = interaction.options.getSubcommand(true);
|
||||||
if (command == "remove") {
|
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 = [];
|
const choices = [];
|
||||||
for (const tag of blacklist) {
|
for (const tag of blacklist) {
|
||||||
if (tag != "" && (value == "" || tag.startsWith(value.trim())))
|
if (value == "" || tag.startsWith(value.trim()))
|
||||||
choices.push(tag);
|
choices.push(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (choices.length == 0)
|
console.log(choices);
|
||||||
return;
|
|
||||||
|
|
||||||
await interaction.respond(choices.map(choice => ({ name: choice, value: choice })))
|
await interaction.respond(choices.map(choice => ({ name: choice, value: choice })))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue