MessageCollector not working

I am trying to get the content of the response so I can save it as a variable and move onto the next bit of information but I can't seem to work out how to get the message collector to work. I've tried 3 different methods and I really don't know what to do now. My codes current state:
} else if (interaction.options.getSubcommand() === 'newentry') {
let type = interaction.options.getString('type')

if (type === "character") {
await interaction.reply(`Creating new \`${type}\` entry. Have all information to hand, will auto cancel in \`300 seconds\`. Reply to the messages for it to work.`)
.then(() => {
sleep(3000)
let NameAsk = interaction.followUp('What is the name of the character? Ensure it is properly capitalised.')
.then(CollectedName => {
const collectorFilter = m => m.author.id === interaction.author.id
interaction.channel.awaitMessages({ filter: collectorFilter, max: 1, time: 30000, errors: ['time'] })
.then(CollectedName => {
NameAsk.delete();
interaction.followUp(`${CollectedName.content} is the provided name.`);
})
})
})
}
}
} else if (interaction.options.getSubcommand() === 'newentry') {
let type = interaction.options.getString('type')

if (type === "character") {
await interaction.reply(`Creating new \`${type}\` entry. Have all information to hand, will auto cancel in \`300 seconds\`. Reply to the messages for it to work.`)
.then(() => {
sleep(3000)
let NameAsk = interaction.followUp('What is the name of the character? Ensure it is properly capitalised.')
.then(CollectedName => {
const collectorFilter = m => m.author.id === interaction.author.id
interaction.channel.awaitMessages({ filter: collectorFilter, max: 1, time: 30000, errors: ['time'] })
.then(CollectedName => {
NameAsk.delete();
interaction.followUp(`${CollectedName.content} is the provided name.`);
})
})
})
}
}
And the error I am getting:
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Collection>".] {
code: 'ERR_UNHANDLED_REJECTION'
}
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Collection>".] {
code: 'ERR_UNHANDLED_REJECTION'
}
I don't think the error is related to my issue, I think thats because I didn't catch the time error. But I'm not sure why it wont give me the message. Any help is much apriciated.
5 Replies
d.js toolkit
d.js toolkit17mo 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!
MrEthλn
MrEthλnOP17mo ago
Node is v20.something Djs is v14.11.something
d.js docs
d.js docs17mo ago
guide Other Interactions: Building and responding with modals read more
MrEthλn
MrEthλnOP17mo ago
I intend to ask for more than just one thing with more follow ups: to make the example attached below would they work for that?
MrEthλn
MrEthλnOP17mo ago
alright thanks
Want results from more Discord servers?
Add your server