【问题标题】:DiscordJS: guildMemberAdd console.log not returning anythingDiscordJS:guildMemberAdd console.log 不返回任何内容
【发布时间】:2022-01-23 01:21:41
【问题描述】:

服务器成员意图已在此应用程序的不和谐开发者门户中打开。

这是我的代码:

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

没有任何东西被记录到控制台。

我做错了什么?

【问题讨论】:

标签: javascript discord.js


【解决方案1】:

您的<Client> 声明中缺少GUILD_MEMBERS 意图。

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS] });

【讨论】:

    猜你喜欢
    • 2020-04-27
    • 2019-04-06
    • 2012-02-15
    • 2020-09-07
    • 2021-11-22
    • 2015-11-06
    • 2013-11-14
    • 2014-03-23
    • 2012-08-25
    相关资源
    最近更新 更多