DiscordJS-Template/commands/examples/login.example.js

39 lines
1.1 KiB
JavaScript

import {
ActionRowBuilder,
ModalBuilder,
SlashCommandBuilder,
TextInputBuilder,
TextInputStyle
} from 'discord.js';
export const data = new SlashCommandBuilder()
.setName('login')
.setDescription('Opens a login pop-up.');
/** @param {ModalSubmitInteraction} interaction */
export async function modalSubmit(interaction) {
await interaction.reply({ content: 'Successfully submitted Form!', ephemeral: true });
}
/** @param {ChatInputCommandInteraction} interaction */
export async function execute(interaction) {
const modal = new ModalBuilder().setCustomId('login-modal').setTitle('Login Form');
const user = new ActionRowBuilder().addComponents(
new TextInputBuilder()
.setCustomId('user')
.setLabel('Enter username:')
.setStyle(TextInputStyle.Short)
.setRequired(true)
);
const password = new ActionRowBuilder().addComponents(
new TextInputBuilder()
.setCustomId('password')
.setLabel('Enter password:')
.setStyle(TextInputStyle.Short)
.setRequired(true)
);
modal.addComponents(user, password);
await interaction.showModal(modal);
}