interaction-kit
interaction-kit copied to clipboard
Type Work
Using alii's type ideas
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/ianmitchell/interaction-kit/EF4FBvbMVvW5YdZpvoAws7zSCoGw
✅ Preview: https://interaction-kit-git-autocomplete-types-ianmitchell1.vercel.app
Test script for this:
import { NumberInput, SlashChoiceList, SlashCommand, StringInput } from "packages/interaction-kit/src";
const choices = SlashChoiceList.create({
key: "choice value",
label: "value",
term: "phrase"
});
const command = new SlashCommand({
name: "test",
description: "test",
options: [
new StringInput({ name: "string", required: true, description: "required string" }),
new StringInput({ name: "choice", required: true, description: "string input", choices }),
new NumberInput({ name: "numeral", description: "number input" })
],
handler: (interaction) => {
interaction.options.string // should return value | undefined
interaction.options.numeral // should return value | undefined
// which is better (watch for name conflicts):
interaction.options.choice === choices.key // returning comparing strings
interaction.options.choice // returns keyof choices
interaction.options
})
})
just stick it in the top level. Includes some notes for later, pausing this to get the new types out