Component

You can create new components in app/component

Decorator

parameter
type
required

id

string

type ComponentType = "modal" | "button" | "select" | "text-input";

Template

import { Client } from "discord.js";
import { Component, Automatic } from "engine";

@Component("my_select_menu", "select")
export default class MySelectMenuComponent {
	public static async callback(client: Client, interaction: Automatic<"select">) {
		const selectedValue = interaction.values[0];
		await interaction.reply(`You selected ${selectedValue}!`);
	}
}

Automatic types

You can use Automatic<T> instead of any

interaction: Automatic<"select"> // all types from ComponentType are available

Is the same with

interaction: StringSelectMenuInteraction

Last updated