I'm trying to make a Bot, which sends the user a message via DM when they join the server. However when somebody joins the server nothing happens
const { group } = require('console')
const Discord = require('discord.js')
const fs = require('fs')
const config = JSON.parse(fs.readFileSync('config.json', 'utf8'))
const client = new Discord.Client()
client.on('guildMemberAdd', member => {
member.send("Message!");
console.log('Welcomemessage sent to' + client.user.tag);
});
client.login(config.token)
There is nothing in the console as well
Before you start with anything you need to check from Discord Developer Portal that you had already enabled PRESENCE INTENT
& SERVER MEMBERS INTENT
from Bot Settings
This is your code:
const { group } = require('console')
const Discord = require('discord.js')
const fs = require('fs')
const config = JSON.parse(fs.readFileSync('config.json', 'utf8'))
client.on('guildMemberAdd', member => {
member.send("Message!");
console.log(`Welcome message sent to: ${member.user.tag}`);
});
client.login(config.token)
Stay Safe.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.