簡體   English   中英

如何獲取發送郵件的用戶的ID?

[英]How do I get the ID of a user that sent the message?

我想提到發送命令的用戶。 我知道我的代碼風格很怪異,但是我喜歡JavaScript之類的函數。

所以這就是我嘗試過的,它提到了使用發送的參數的用戶。 因此,例如,如果您執行!mention <user_id> ,則會提及該用戶。 我想從發送的用戶中自動檢測到這一點。

function pingFunction(arguments, receivedMessage) {
  if (arguments > 0) {
    receivedMessage.channel.send("<@" + arguments + ">");
  } else {
    receivedMessage.channel.send("<@" + arguments + ">");
  }
}

提前致謝!

該辦法讓誰發送了消息的人的ID message.author.id ,或在你的情況, receivedMessage.author.id

從那里,您可以替換receivedMessage.channel.send("<@" + arguments + ">") receivedMessage.channel.send("<@" + message.author.id + ">");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM