For some reason, no matter what I try, the awaitMessages function never gets any messages from the channel. I've tried awaiting it, I've tried using different functions like collectors and yet nothing is picking up anything. Original commands are picked up fine but not when awaiting messages.
const filter = m => m.author == interaction.author;
interaction.reply('Recieved')
.then(() =>
interaction.channel.awaitMessages(filter, {
max: 1,
time: 3000,
errors: ['time']
})
.then(collected => {
interaction.channel.send(collected.first());
})
.catch(collected => {
interaction.channel.send('Timeout');
})
);
I've tracked down this issue! In case anyone else's having this problem as I think it could be common in discord.js v13.
The problem lies in intents. The intents that the Discord.js guide suggests are [Intents.FLAGS.GUILDS]; however, this does not allow for direct reading of messages. If you want to use awaitMessages or even add a listener to the message event that you need to include the "GUILD_MESSAGES" intent.
Interaction#author does not exist, and comparing objects can give unexpected results. Use Interaction#user and compare the IDs
const filter = m => m.author.id == interaction.user.id