let messages = await interaction.channel.messages.fetch(); messages.then(async (messages) => { const output = messages.array().reverse().map(m => `${new Date(m.createdAt).toLocaleString('en-US')} - ${m.author.tag}: ${m.attachments.size > 0 ? m.attachments.first().proxyURL : m.content}`).join('\n'); console.log(output) })y cuando obtengo este registro de consola, mi consola registra este error:
C:\Users\test7\Desktop\ThunderBot\events\bot\slash-interactionCreate.js:195 messages.then(async (messages) => { ^ TypeError: messages.then is not a functiondatos de interacción.canal: https://hastebin.com/uwocabepoq.yaml
Ya estás await los mensajes. Esto proporciona la Collection de mensajes que no tiene el método .then ( .then existe en las instancias de Promise , pero no en las instancias de Collection sin cambios). O elimine la await para obtener la instancia de Promise o ejecútela sin el .then
Quitando await
let messages = interaction.channel.messages.fetch(); messages.then(async (messages) => { const output = messages.array().reverse().map(m => `${new Date(m.createdAt).toLocaleString('en-US')} - ${m.author.tag}: ${m.attachments.size > 0 ? m.attachments.first().proxyURL : m.content}`).join('\n'); console.log(output) }) Eliminando .then
let messages = await interaction.channel.messages.fetch(); const output = messages.array().reverse().map(m => `${new Date(m.createdAt).toLocaleString('en-US')} - ${m.author.tag}: ${m.attachments.size > 0 ? m.attachments.first().proxyURL : m.content}`).join('\n'); console.log(output)