1

I am trying to fetch every message in a specific channel and log it to console, I've been trying to crack this for a while now but I can never fetch more than 100 messages, I can't figure out how to loop fetchMessages so I can get more than 100, here is the code I have:

const Discord = require('discord.js'); //dependency
const client = new Discord.Client();



client.on('ready', () => { //when the bot turns on, it says its on in console
  console.log(`Logged in as ${client.user.tag}!`);
  client.channels.get('790493949474635797').fetchMessages({limit:100}).then(messages=>{
    messages
    .forEach(message =>console.log(`"${message.author.tag}", ${
      (() => {
        const unixTimestamp = message.createdTimestamp
        const dateObject = new Date(unixTimestamp)
        var d = new Date(unixTimestamp);
        var utc = d.getTime(unixTimestamp);
        var nd = new Date(utc + (3600000*0))
        return nd.toLocaleString()
      })()}:\n${message.content}`))
  })
});

Any help would be appreciated!

0 Answers0