feat: add /move command

This commit is contained in:
Isaac
2022-10-31 21:15:44 +00:00
parent d10965d541
commit 9f18958c75
6 changed files with 130 additions and 16 deletions

View File

@@ -8,5 +8,26 @@ module.exports = class CategoryCompleter extends Autocompleter {
});
}
async run(value, comamnd, interaction) { }
/**
* @param {string} value
* @param {*} command
* @param {import("discord.js").AutocompleteInteraction} interaction
*/
async run(value, command, interaction) {
/** @type {import("client")} */
const client = this.client;
let categories = await client.prisma.category.findMany({ where: { guildId: interaction.guild.id } });
const ticket = await client.prisma.ticket.findUnique({ where: { id: interaction.channel.id } });
if (ticket) categories = categories.filter(category => ticket.categoryId !== category.id);
const options = value ? categories.filter(category => category.name.match(new RegExp(value, 'i'))) : categories;
await interaction.respond(
options
.slice(0, 25)
.map(category => ({
name: category.name,
value: category.id,
})),
);
}
};