I was creating a function that runs every second and updates a channel name to show the number of members in my server but it is just showing up as 0 members. There a no errors for the command. Here is the code:
const guild = bot.guilds.cache.get("778322604863258686")
setInterval(function () {
var memberCount = guild.members.cache.filter(member => !member.user.bot).size;
var memberCountChannel = bot.channels.cache.get("779888675915169802");
memberCountChannel.setName(`${memberCount}`)
}, 1000);