Send a Modal to members when they join the sever. #9077
-
Hello, I am trying to send a modal to the member upon joining the server to gather some data. I am trying this but I am getting an error const {
Events,
ModalBuilder,
TextInputBuilder,
ActionRowBuilder,
TextInputStyle,
} = require('discord.js');
module.exports = {
name: Events.GuildMemberAdd,
once: true,
async execute(member) {
try {
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');
const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
.setLabel("What's your favorite color?")
.setStyle(TextInputStyle.Short);
const hobbiesInput = new TextInputBuilder()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
.setStyle(TextInputStyle.Paragraph);
const firstActionRow = new ActionRowBuilder().addComponents(
favoriteColorInput
);
const secondActionRow = new ActionRowBuilder().addComponents(
hobbiesInput
);
modal.addComponents(firstActionRow, secondActionRow);
await member.send({
content: 'Welcome to the server!',
components: [modal],
});
} catch (error) {
console.log('error in guildMemberAdd event', error);
}
},
}; Here is the error I get
I was able to send a button to the user just fine. But when I tried a textInputBuilder it give an error about the type as well. Thank you. |
Beta Was this translation helpful? Give feedback.
Answered by
Jiralite
Jan 18, 2023
Replies: 1 comment
-
A modal is not a component. Furthermore, modals can only be sent as a response to an interaction. See the guide on them here. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
kyranet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A modal is not a component. Furthermore, modals can only be sent as a response to an interaction. See the guide on them here.