import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, Client, GatewayIntentBits, ModalBuilder, TextInputBuilder, TextInputStyle } from "discord.js"; const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages ], }); client.on("messageCreate", async (message) => { if (message.author.bot) return; const button = new ActionRowBuilder().addComponents( new ButtonBuilder() .setCustomId("test") .setLabel("Test") .setStyle(ButtonStyle.Secondary), ); const forum = await message.guild.channels.create( { name: "test", type: ChannelType.GuildForum, } ) forum.threads.create({ name: "Test forum", message: { content: "Message forum", components: [button] } }) }) client.on("interactionCreate", async (interaction) => { if (interaction.isButton()) { const modal = new ModalBuilder() .setCustomId("test") .setTitle("Test"); const field = new ActionRowBuilder().addComponents( new TextInputBuilder() .setCustomId("field") .setLabel("Test field") .setStyle(TextInputStyle.Paragraph) ); modal.addComponents([field]); return await interaction.showModal(modal); } if (interaction.isModalSubmit()) { await interaction.deferReply(); return await interaction.followUp("Done") } }) client.login("TOKEN");