Files
ArvaldDos-Bot/commands/common/autocompletes.ts
2024-08-06 08:06:31 +00:00

13 lines
406 B
TypeScript

import type { AutocompleteInteraction } from "discord.js";
import { get_all_items } from "../../db";
export async function item_name_autocomplete(interaction: AutocompleteInteraction) {
return await interaction.respond((await get_all_items()).filter(
(item) => item.name.startsWith(interaction.options.getFocused(true).value)
).map(
(item) => ({ name: item.name, value: item.name })
));
}