all repos — stealth-developers @ 01d2e9fd4ff1d1ff4d424b2b2a5e0719a1cf763a

src/interactions/commands/bug/button.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
import {
	ActionRowBuilder,
	type ChatInputCommandInteraction,
	type Client,
	StringSelectMenuBuilder,
	StringSelectMenuOptionBuilder,
} from "discord.js";
import { PROJECT_MAP } from "./shared.ts";

export async function execute(
	_client: Client,
	interaction: ChatInputCommandInteraction,
) {
	const tgtUser = interaction.options.getUser("user", true);

	const options = Object.entries(PROJECT_MAP).map(([key, project]) =>
		new StringSelectMenuOptionBuilder()
			.setLabel(project.displayName)
			.setValue(key),
	);

	const selectMenu = new StringSelectMenuBuilder()
		.setCustomId("bug:project-select")
		.setPlaceholder("select a project to report a bug")
		.addOptions(...options);

	const selectRow =
		new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu);

	await interaction.reply({
		content: `📝 <@${tgtUser.id}>, use the dropdown below to select the project
		  you want to report a bug for. in the future, you can also use the
			</bug report:${interaction.commandId}> command to report bugs.`
			.replace(/\s+/g, " ")
			.trim(),
		components: [selectRow],
	});
}

export const buttonCommand = {
	execute,
};