【问题标题】:Discord.js Guild Member AddDiscord.js 公会成员添加
【发布时间】:2023-04-09 22:52:01
【问题描述】:

我正在制作一个机器人来检测用户何时加入。当我的测试帐户加入时,下面的代码不起作用。它仅在用户第一次加入时才有效。如果是这样,我怎样才能让它每次都工作。

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}`);
      });

【问题讨论】:

  • 您是否启用了所需的意图? discordjs.guide/popular-topics/…
  • 我启用了这些。
  • 你调试了吗?尝试在事件中记录以确保它正在发出
  • 是的。我已经检查过了,我什么也没得到。

标签: discord.js


【解决方案1】:

您可能必须在 Discord Developer Portal 上的机器人设置中启用 Presence Intent,以便它能够检测到新成员。Here's an screenshot

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-02
    • 2021-05-26
    • 2022-01-11
    • 1970-01-01
    • 2020-11-21
    • 2021-06-27
    • 2020-08-15
    相关资源
    最近更新 更多