Reputation: 1
I had had a bot that had the feature to show the member count and user account creation date whenever a new user joins a welcome channel along with a message, and it used to work fine, but after being away from discord for about 6 months and coming back yesterday, I found out that it didn't work anymore, but I can't figure out what changes I have to make to the code :(, can anybody help me out?
const Discord = require('discord.js');
const bot = new Discord.Client();
const PREFIX = "?";
const fs = require('fs');
bot.commands = new Discord.Collection();
bot.on('guildMemberAdd', member =>{
const channel = member.guild.channels.cache.find(channel => channel.name === "welcome");
if(!channel) return;
channel.send(`Welcome, ${member}, please read the rules in #đŸ“‹rules! Subsequently, please introduce yourself in #introductions and provide your timezones.`)
let dateFormat = require('dateformat')
let embed = new Discord.MessageEmbed()
.setTitle("__**Details**__")
.setColor(0xAAEDF9)
.setAuthor(`${member.user.tag} Has Joined.`, member.user.displayAvatarURL,)
.setThumbnail(member.user.displayAvatarURL)
.addField('*Account created*', dateFormat(member.user.createdAt, "mm:dd:yyyy h:MM"), true)
.addField('\u200B','\u200B')
.addField('*Member Count*', member.guild.memberCount, true)
channel.send(embed);
});
Upvotes: 0
Views: 514
Reputation: 485
Discord has very recently applied changes to how certain privacy sensitive user data is sent. Presence and activity data (.presence) as well as events based around guild members (guildMemberAdd, guildMemberRemove, guildMemberUpdate, presenceUpdate) are now explicitly opt-in by either toggling in the developer dashboard
You need to enable the members intent from the discord developers portal
Upvotes: 1