interactive data collection

I have an "interactive" chat with the bot, it asks me questions, I answer them and it saves that information to send it in a single message later on x channel, it worked normally, but I wanted to add some buttons so that depending on what they choose in the buttons the bot will continue a different code, the fact is that with the buttons I could only implement 1 action and the action is continued in a 'client.on('messageCreate', async (message) => {' because if not I won't It worked, but when collecting data, it only collects the first one and leaves the rest as undefined
js
const userId = message.author.id;
if (datosTicket[userId] && datosTicket[userId].tipo_solicitud === 'Live/Streaming Class') {
console.log(datosTicket);
if (!datosTicket[userId].tipo_transmicion || datosTicket[userId].tipo_transmicion === 'undefined') {
datosTicket[userId].tipo_transmicion = message.content;
console.log(datosTicket);
await message.author.send('At what time in UTC time do you want the transmission to be and what day in DD/MM format');
} else if ((!datosTicket[userId].hora || datosTicket[userId].hora === 'undefined') && datosTicket[userId].tipo_transmicion) {
datosTicket[userId].hora = message.content;
console.log(datosTicket);
await message.author.send('Any additional notes?');
} else if ((!datosTicket[userId].nota || datosTicket[userId].nota === 'undefined') && datosTicket[userId].hora) {
datosTicket[userId].nota = message.content;
}
console.log(datosTicket);
js
const userId = message.author.id;
if (datosTicket[userId] && datosTicket[userId].tipo_solicitud === 'Live/Streaming Class') {
console.log(datosTicket);
if (!datosTicket[userId].tipo_transmicion || datosTicket[userId].tipo_transmicion === 'undefined') {
datosTicket[userId].tipo_transmicion = message.content;
console.log(datosTicket);
await message.author.send('At what time in UTC time do you want the transmission to be and what day in DD/MM format');
} else if ((!datosTicket[userId].hora || datosTicket[userId].hora === 'undefined') && datosTicket[userId].tipo_transmicion) {
datosTicket[userId].hora = message.content;
console.log(datosTicket);
await message.author.send('Any additional notes?');
} else if ((!datosTicket[userId].nota || datosTicket[userId].nota === 'undefined') && datosTicket[userId].hora) {
datosTicket[userId].nota = message.content;
}
console.log(datosTicket);
4 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Ruthless_Mercy_
Ruthless_Mercy_OP15mo ago
These are the console logs, it only gave me 2 of the 4 that I asked for, after those two it literally only skips the part of collecting data, and sends the ticket
No description
Ruthless_Mercy_
Ruthless_Mercy_OP15mo ago
In addition to that, the bot somehow "loses" the user's name, since the thread it creates as undefined should be the user's name plus the date, which before it did so (I'm regretting adding those buttons xd )
No description
Ruthless_Mercy_
Ruthless_Mercy_OP15mo ago
I already solved it using other logic in my code moaistoneab
Want results from more Discord servers?
Add your server