channel.messages.fetch not working
skzhengkai opened this issue · comments
Which package has the bugs?
The core library
Issue description
Message.channel.messages.fetch is not working. No errors are thrown, it simply seems to never finish.
Code sample
client.on('messageCreate', async (message) => {
if (message.content.startsWith('!getlast')) {
const channel = message.channel;
console.log(`channel: ${channel.name}`)
const messages = await message.channel.messages.fetch({ limit: 20 });
console.log(`messages: ${messages.size}`)
const filteredMessages = messages.filter(msg => !msg.author.bot).reverse();
console.log(filteredMessages)
const formattedMessages = filteredMessages.map((msg, index) => `${index + 1}. ${msg.author.username} (${msg.createdAt.toLocaleString()}): ${msg.content}`);
console.log(`\`\`\`\n${formattedMessages.join('\n')}\n\`\`\``);
}
});
Package version
2.15.1
Node.js version
18.12.1
Operating system
No response
Priority this issue should have
Medium (should be fixed soon)
Checklist
- I have searched the open issues for duplicates.
- I have shared the entire traceback.
- I am using a user token (and it isn't visible in the code).
Additional Information
No response
The issue was using Replit IP.