Reputation: 27
I'm trying to fetch all the messages in a channel, but the error I get is cannot send an empty message.
var str = bot.channels.cache.get('729038947380101170').messages.fetch({ limit: 10 });
message.channel.send(str);
The channel has messages for sure. What is wrong with the fetch()
?
Upvotes: 0
Views: 1746
Reputation: 5174
There is nothing wrong with fetch()
it just returns a promise so you need to await
that promise
const channel = bot.channels.cache.get('729038947380101170')
const messages = await channel.messages.fetch({ limit: 10 });
messages.forEach(msg => message.channel.send(msg.content));
Upvotes: 1