discord.js - Discord.js 公会成员添加
问题描述
我正在制作一个机器人来检测用户何时加入。当我的测试帐户加入时,下面的代码不起作用。它仅在用户第一次加入时才有效。如果是这样,我怎样才能让它每次都工作。
client.on('guildMemberAdd', member => {
// Send the message to a designated channel on a server:
const channel = member.guild.channels.cache.find(ch => ch.name === 'general-chat');
// Do nothing if the channel wasn't found on this server
if (!channel) return;
// Send the message, mentioning the member
channel.send(`Welcome to the server, ${member}`);
});
解决方案
您可能必须在Discord Developer Portal上的机器人设置中启用 Presence Intent ,这样才能检测到新成员。这是一个截图。
推荐阅读
- snowflake-cloud-data-platform - 使用 SnowFlake 查询多级数组
- c++ - C ++包括多个文件中的模板类
- python - 如何修改我的代码以输出百分比和数字?
- python - 理解用浮士德表和分区连接浮士德主题
- bash - 试图将命令传递给 sftp
- reactjs - Firebase ReactJS useEffect TypeError:无法读取 null 的属性“uid”
- python - 无论如何我可以排除一些 sympy 求解器的解决方案吗?
- c - MPI 共享内存和四精度的分段错误
- python - 如何通过 POST 表单接收 Excel 文件,然后用 pandas 打开它?(Python3 aiohttp)
- c++ - 为什么不能将两个地址加在一起?