3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Discord.jsでフォームを作る

Posted at

用途・目的

サークルのDiscordのメンバー管理を自動化したい。人間がいちいち対応していると、初見さんにとって参加の敷居が高いかなと思ったから、学籍番号や電話番号の入力フォームを作る。

完成系

image.png

コード

const modal = new ModalBuilder()
    .setCustomId(interaction.customId)
    .setTitle("参加申請書");

const studentIDInput = new TextInputBuilder()
    .setCustomId("student-id")
    .setLabel("学籍番号(半角)")
    .setPlaceholder("J01122334")
    .setRequired(true)
    .setStyle(TextInputStyle.Short);

const studentNameInput = new TextInputBuilder()
    .setCustomId("student-name")
    .setLabel("氏名")
    .setPlaceholder("田中 太郎")
    .setRequired(true)
    .setStyle(TextInputStyle.Short);


const studentPhoneNumber = new TextInputBuilder()
    .setCustomId("student-phone")
    .setLabel("電話番号")
    .setPlaceholder("080-XXXX-XXXX")
    .setRequired(true)
    .setStyle(TextInputStyle.Short);

const firstActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(studentIDInput);
const secondActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(studentNameInput);
const thirdActionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(studentPhoneNumber);


modal.addComponents(firstActionRow, secondActionRow, thirdActionRow);
await interaction.showModal(modal);

これを適当なintractionにひっかけておく。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?