Message collector not working in thread

On discordjs 14.11.0. I cannot get a message collector to work in threads despite having no issue with other collectors such as for components. I've confirmed the thread is valid, as I can send messages to the thread using the same handle at the same point in the code. I have tried to log every event the collector triggers and I get a big load of nothing in the console, but it appears to instantiate correctly.
const collector = thread.createMessageCollector();

collector.on('collect', async m => {
console.log(`Collected ${m.content} | ${m.author.tag}`);
// Find stickied message if it exists or create a new one
const sticky_message: Message | undefined = event.sticky_message_id ? thread.messages.cache.find(m => m.id === event.sticky_message_id) : undefined;

// If the message exists, edit it
if (sticky_message)
{
const embed = EventJobs.getStickyEmbed(event);
await sticky_message.edit({embeds: [embed]});
}
// Otherwise, create a new message
else
{
const embed = EventJobs.getStickyEmbed(event);
const message = await thread.send({embeds: [embed]});

// Save the sticky message id to the event
event.sticky_message_id = message.id;
await event.save();
}
});

collector.on('dispose', console.error);
collector.on('end', collected => console.log(`Collected ${collected.size} items`));
collector.on('ignore', console.error);

collector.handleCollect = async (message: Message) => {
console.log("Handle collect called:", message.content);
};
collector.handleDispose = async (message: Message) => {
console.log("Handle dispose called:", message.content);
};

console.log(`Created message collector for thread ${thread.id}`);
const collector = thread.createMessageCollector();

collector.on('collect', async m => {
console.log(`Collected ${m.content} | ${m.author.tag}`);
// Find stickied message if it exists or create a new one
const sticky_message: Message | undefined = event.sticky_message_id ? thread.messages.cache.find(m => m.id === event.sticky_message_id) : undefined;

// If the message exists, edit it
if (sticky_message)
{
const embed = EventJobs.getStickyEmbed(event);
await sticky_message.edit({embeds: [embed]});
}
// Otherwise, create a new message
else
{
const embed = EventJobs.getStickyEmbed(event);
const message = await thread.send({embeds: [embed]});

// Save the sticky message id to the event
event.sticky_message_id = message.id;
await event.save();
}
});

collector.on('dispose', console.error);
collector.on('end', collected => console.log(`Collected ${collected.size} items`));
collector.on('ignore', console.error);

collector.handleCollect = async (message: Message) => {
console.log("Handle collect called:", message.content);
};
collector.handleDispose = async (message: Message) => {
console.log("Handle dispose called:", message.content);
};

console.log(`Created message collector for thread ${thread.id}`);
The bot has admin perms, all presence enabled, and is member of the thread.
12 Replies
d.js toolkit
d.js toolkit10mo 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!
Ghetto
Ghetto10mo ago
Just updated to 14.12.1, no difference
treble/luna
treble/luna10mo ago
do you have the messagecontent and GuildMessages intent? also iirc createMessage.... returns a promise
Ghetto
Ghetto10mo ago
createMessageCollector isn't async if that's what you mean I will double check intents, I imagine the problem must lie there somewhere and it may have been misconfigured, as I don't believe there's anything wrong with the code Is there a way to manage intents without re-inviting the bot to the server?
treble/luna
treble/luna10mo ago
you dont have to reinvite it? just add them restart it and done
Ghetto
Ghetto10mo ago
ah okay, preciate it 😄 I believe it already had all intents, is there anything else I need to configure besides what I showed in the attached image? I gave the bot admin perms which I believe is the highest levels when I invited it
treble/luna
treble/luna10mo ago
show your client constructor
Ghetto
Ghetto10mo ago
ah
new BotClient({ intents: [GatewayIntentBits.Guilds] });
new BotClient({ intents: [GatewayIntentBits.Guilds] });
I see
treble/luna
treble/luna10mo ago
that would be your issue
Ghetto
Ghetto10mo ago
❤️ Is there a way to give it all intents without specifying them all?
treble/luna
treble/luna10mo ago
no that would also cause unecessary memory usage
Ghetto
Ghetto10mo ago
understood, appreciate the help 👍