[英]Discord Welcome Message DM
I'm trying to make a Bot, which sends the user a message via DM when they join the server.我正在尝试制作一个 Bot,当用户加入服务器时,它会通过 DM 向用户发送消息。 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在你开始做任何事情之前,你需要从Discord 开发者门户中检查你已经从机器人设置中启用了
PRESENCE INTENT
和SERVER MEMBERS INTENT
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.注意安全。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.