items part 1
This commit is contained in:
12
commands/common/autocompletes.ts
Normal file
12
commands/common/autocompletes.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
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 })
|
||||
));
|
||||
}
|
||||
|
||||
2
commands/common/error.ts
Normal file
2
commands/common/error.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export class BotError extends Error {};
|
||||
|
||||
Reference in New Issue
Block a user