如何在discord.js中标记玩家并接收他们的discord-id



我一直在试图弄清楚如何标记用户,然后接收他们的用户id。我试图为此编写代码,但问题是在特定模式中两次接收用户id。例如:

我的代码:第一用户-1234566第二个用户-12345761234576第三用户-123458612345861234586

我希望代码像这样运行:

第一用户-1234566第二用户-1234576第三用户-1234586

下面是我的代码:("加入"是我加入游戏的一系列人。这非常有效(

client.on('message', function(playerFind) {
const playerID = playerFind.content;
if (playerFind.author.bot) return;
let mention = playerFind.mentions.users.first();
if((playerID.startsWith('!find id ')) && (mention) && (joined.length > 0)){
for(var i = 0; i < joined.length; i++){
if(mention.id === user[joined[i]].getID()) {
playerFind.channel.send(mention.id);
}
}
}
})

自2019年年中以来,我就没有使用过discord.js,但当时它应该是

client.on("message", (message) => {
var command = message.content.split(" ")[0];
if(!command.startsWith(prefix)) return;
if(command === "getid") {
message.channel.send(message.content.mentions.users.first().id)
}
});

我相信,正如我所说,已经有一段时间了。

最新更新