export function TemplateAutocomplete(): ClassDecorator {
return createClassDecorator((target: Command) =>
createProxy(target, {
apply(target) {
target.autocompleteRun = async (
interaction: AutocompleteInteraction,
) => {
const template = interaction.options.getString("template");
if (!template) return;
const data = (
await db.template.findMany({ select: { id: true } })
).map((x) => x.id);
const fuse = new Fuse(data);
console.log(
(template ? fuse.search(template).map((x) => x.item) : data)
.slice(0, 25)
.map((x) => ({
name: x,
value: x,
})),
);
return interaction
.respond(
(template ? fuse.search(template).map((x) => x.item) : data)
.slice(0, 25)
.map((x) => ({
name: x,
value: x,
})),
)
.catch(() => {});
};
},
}),
);
}
export function TemplateAutocomplete(): ClassDecorator {
return createClassDecorator((target: Command) =>
createProxy(target, {
apply(target) {
target.autocompleteRun = async (
interaction: AutocompleteInteraction,
) => {
const template = interaction.options.getString("template");
if (!template) return;
const data = (
await db.template.findMany({ select: { id: true } })
).map((x) => x.id);
const fuse = new Fuse(data);
console.log(
(template ? fuse.search(template).map((x) => x.item) : data)
.slice(0, 25)
.map((x) => ({
name: x,
value: x,
})),
);
return interaction
.respond(
(template ? fuse.search(template).map((x) => x.item) : data)
.slice(0, 25)
.map((x) => ({
name: x,
value: x,
})),
)
.catch(() => {});
};
},
}),
);
}