Possible duplicate with message.content doesn't have any value in Discord.js v14
I'm trying to add a feature to my discord bot where it will send embeds and collect a series of replies and return a final result with all answers combied. Basically like a quiz with multiple questions but instead of evaluating answers, I will collect and use answers later on in a final reply from the bot.
(Like Apollo Event Creator Bot's /event command, if you will)
I was trying to do it step by step. So sent the first message in an embed. But when I create the collector (I also will try to create the collector on user dm and return final answer on the channel that command is executed but that's another question) and provide inputs from a member account, the collected content is always an empty string ('')
I've tried various possible approachs but no matter what I do, it always return an empty string as content.
I think it's because I call the command execution in module export (since I collect commands from their files and execute them on main file) but I wasn't able to find a fix.
Here is my collector code:
module.exports = {
data:command,
async execute(interaction) {
await interaction.reply({ embeds: [NewEmbed] })
const collector = interaction.channel.createMessageCollector({ time: 15000 });
collector.on('collect', m => {
console.log(`Collected ${m.content}`);
});
collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
}
}
I basically use DiscordJs Command Handling to call and execute my commands in their own file.
In above code m.content is always an empty string. Even though it collects the correct number of replies.
client.on('interactionCreate', async interaction => {
if (!interaction.isChatInputCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
And that's how I execute my commands on the main file. All other commands work just fine so there is no error there (command calling wise)
Really bugging me for days. Thanks for the replies in advance!