0

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

Jakye
  • 6,440
  • 3
  • 19
  • 38
Knocklive
  • 35
  • 4
  • 1
    Does this answer your question? [None of my discord.js guildmember events are emitting, my user caches are basically empty, and my functions are timing out?](https://stackoverflow.com/questions/64559390/none-of-my-discord-js-guildmember-events-are-emitting-my-user-caches-are-basica) – Lioness100 Mar 13 '21 at 18:54

1 Answers1

2

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.

Just4you
  • 66
  • 1
  • 9