messages

getting messages of a discord channel?
channel.messages.fetch().then(messages => {
console.log(messages);
});
channel.messages.fetch().then(messages => {
console.log(messages);
});
get TypeError: Cannot read properties of undefined (reading 'fetch')
12 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
treble/luna
treble/luna12mo ago
Channel is not a TextBasedChannel
Deerlo
Deerlo12mo ago
I get channel from const channel = await interaction.client.channels.cache.get(config.channels.jobPickups);; so what do I need?
treble/luna
treble/luna12mo ago
The guilds intent And getting from cache isnt async, no need to await And if you have the guilds intent, your id might be invalid
Jordan
Jordan12mo ago
Yes
Deerlo
Deerlo12mo ago
so do interaction.guild? can u explain me about guilds intent
d.js docs
d.js docs12mo ago
guide Popular Topics: Gateway Intents read more
treble/luna
treble/luna12mo ago
Thats not an intent
Deerlo
Deerlo12mo ago
Deerlo
Deerlo12mo ago
I have it enabled it refers to a text channel, I am able to send messages directly to this channel, now I want to retrieve all messages from it now it works, getting this channel is wrapped in async function, forgot to await, cheers channel.messages.fetch().then(messages => { }); Is there a limit of how many messages it will fetch?
treble/luna
treble/luna12mo ago
50 by default 100 max
Deerlo
Deerlo12mo ago
thank you