【问题标题】:Sending a message to a member (discord.js)向成员发送消息 (discord.js)
【发布时间】:2020-10-08 20:17:28
【问题描述】:

如何向与我在另一个分片中的成员发送消息?

我尝试了let member= await client.shard.fetchClientValues('users.cache.get("args[0]")'),但没有成功。

【问题讨论】:

  • 你打算如何识别这个成员?
  • 您好,欢迎来到 StackOverFlow,请通过分享部分代码和详细信息来提供有关问题的更多详细信息。这样人们就可以更快地回答您的问题。
  • 我打算通过他的 id 来识别他,这将在 args [0] 中。

标签: javascript discord discord.js member sharding


【解决方案1】:

如果你能得到他们的身份证试试 client.users.cache.get(id).send(message)

【讨论】:

  • 在client.shard.fetchClientValues里面?
  • 是的,它应该从所有的碎片中看出来
  • 确保您没有将 args[0] 放入“”,如果您这样做,它将查找 args[0] 而不是实际的 ID
【解决方案2】:

假设您将 id 存储在名为 userID 的变量中,那么您可以这样进行:

client.shard.broadcastEval(`
    const user = client.users.cache.get("${userID}");
    if (user) user.send("Your Message");
`);

但是如果在多个分片上发现用户,这可能会多次发送消息,因此请务必牢记这一点;)

【讨论】:

    猜你喜欢
    • 2019-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-12
    • 2021-08-21
    • 2020-04-04
    • 1970-01-01
    相关资源
    最近更新 更多