[英]Function not returning anything at all but console.log returns something
[英]DiscordJS: guildMemberAdd console.log not returning anything
已在 discord 开发人员门户中为此应用程序打开服务器成员意图。
这是我的代码:
const { Client, Collection, Intents } = require('discord.js');
const fs = require('fs');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
client.commands = new Collection();
require('dotenv').config(); //initialize dotenv
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
client.on('guildMemberAdd', member => {
member.guild.channels.get('channelID').send(`Welcome, ${interaction.member.tag}`);
console.log(`test`);
});
//make sure this line is the last line
client.login(process.env.CLIENT_TOKEN); //login bot using token
没有任何内容被记录到控制台。
我做错了什么?
您在<Client>
声明中缺少GUILD_MEMBERS
意图。
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS] });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.