.awaitMessages isn't working

Hi, I'm currently trying to make a quiz where you have to guess a random member of a guild by it's profile picture. Therefore I made this command
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("guess")
.setDescription("Guess a random member of the server by the profile picture"),

async execute(interaction) {

const guildMembers = await interaction.guild.members.fetch();
const randMember = guildMembers.random();

const member = randMember.displayName;

const guessEmbed = new MessageEmbed()
.setColor(randMember.user.accentColor)
.setTitle("Guess that Member!")
.setImage(`${randMember.displayAvatarURL()}`)
.setFooter({text: "developed by Nils#7168"})


//console.log(randMember.displayName)

interaction.reply({ embeds: [guessEmbed], fetchReply: true })
.then(() => {
interaction.channel.awaitMessages({ member, max: 1, time: 15000, errors: ['time'] })
.then(collected => {
interaction.followUp(`<@${collected.first().author.id}> you're right! It was ${member}.`);
})
.catch(collected => {
interaction.followUp(`Looks like nobody got the right answer. It was ${member}.`);
});
});



},
};
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName("guess")
.setDescription("Guess a random member of the server by the profile picture"),

async execute(interaction) {

const guildMembers = await interaction.guild.members.fetch();
const randMember = guildMembers.random();

const member = randMember.displayName;

const guessEmbed = new MessageEmbed()
.setColor(randMember.user.accentColor)
.setTitle("Guess that Member!")
.setImage(`${randMember.displayAvatarURL()}`)
.setFooter({text: "developed by Nils#7168"})


//console.log(randMember.displayName)

interaction.reply({ embeds: [guessEmbed], fetchReply: true })
.then(() => {
interaction.channel.awaitMessages({ member, max: 1, time: 15000, errors: ['time'] })
.then(collected => {
interaction.followUp(`<@${collected.first().author.id}> you're right! It was ${member}.`);
})
.catch(collected => {
interaction.followUp(`Looks like nobody got the right answer. It was ${member}.`);
});
});



},
};
It fetches all members of a guild, picks a random member out of the collection and sends the profile picture with a embed. Then I want to await the Message with the username of the member. Now that's the point that isn't working. Although it sends the username of the member after the 15000ms passed, the bot isn't responding when I send a message with the correct username. It seems like the filter, in my case the member variable isn't working. Why?
1 Reply
Nils
Nils2y ago
Seems like I misunderstood the whole filter thing Ahh I see, will try it Unfortunatly I'm still not getting it to work. I added the filter now that looks like this let filter = message => message.content.startsWith() === member but it is still not responding. Ok today is definitely not my day. Would be message.content.startsWith(member), right? Ok figured out why it wasn't working, forgot the intent GUILD_MESSAGES thanks for your help.