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 toolkit•3y 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/luna•3y ago
Channel is not a TextBasedChannel
Deerlo
DeerloOP•3y ago
I get channel from const channel = await interaction.client.channels.cache.get(config.channels.jobPickups);; so what do I need?
treble/luna
treble/luna•3y 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
Jordan•3y ago
Yes
Deerlo
DeerloOP•3y ago
so do interaction.guild? can u explain me about guilds intent
d.js docs
d.js docs•3y ago
guide Popular Topics: Gateway Intents read more
treble/luna
treble/luna•3y ago
Thats not an intent
Deerlo
DeerloOP•3y ago
Deerlo
DeerloOP•3y 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/luna•3y ago
50 by default 100 max
Deerlo
DeerloOP•3y ago
thank you

Did you find this page helpful?