【问题标题】:Server greetings服务器问候语
【发布时间】:2021-04-15 04:24:36
【问题描述】:

我尝试制作服务器问候消息,但它甚至对我不起作用,我看到您可以尝试使用 ch.name === 'name' 来执行此操作,但我希望我的机器人向具有特定 ID 的频道发送消息

client.on("guildMemberAdd", (member) => {
  const channel = member.guild.channels.cache.find((ch) => ch.id === `channel-id`);
  if (!channel) return;
  channel.send(`Welcome to the server, ${member}!`);
});

【问题讨论】:

  • 用户加入时你想这样做吗?我只是问这个,因为我不确定你为什么要找这个频道
  • 哪个部分不起作用?顺便说一句,如果您使用ch.id,它只能在您的公会 (member.guild) 上找到频道,因为没有其他公会拥有与该 ID 完全相同的频道。每个频道都有不同的 ID。

标签: javascript discord.js


【解决方案1】:

您必须为 guildMemberAdd 事件启用 Intent 才能发出。确保在here启用它们

启用意图后,您可以通过以下方式向客户端添加意图

 const client = new Client({ ws: { intents: ['GUILD_MEMBERS', 'GUILD_MESSAGES', 'GUILD_MESSAGE_REACTIONS']} });

【讨论】:

    【解决方案2】:

    我认为您需要在 Dev Portal 上打开 Privileged Gateway Intents (https://discord.com/developers/applications) gateway intents on

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-25
      • 1970-01-01
      • 2018-12-23
      • 2012-04-28
      • 1970-01-01
      • 1970-01-01
      • 2015-09-20
      相关资源
      最近更新 更多