[英]How to tag player and recieve their discord id in discord.js
I have been trying to figure out how to tag people and then receive their user id.我一直在试图弄清楚如何标记人,然后接收他们的用户 ID。 I attempted to make a code for that but the problem is it is receiving the user-id twice in a particular pattern.我试图为此编写代码,但问题是它以特定模式接收用户 ID 两次。 For example:例如:
My code: FirstUser - 1234566 Second user- 1234576 1234576 Third user - 1234586 1234586 1234586我的代码:第一个用户 - 1234566 第二个用户 - 1234576 1234576 第三个用户 - 1234586 1234586 1234586
I want the code to run like this:我希望代码像这样运行:
First User - 1234566 Second User - 1234576 Third User - 1234586第一个用户 - 1234566 第二个用户 - 1234576 第三个用户 - 1234586
Here is my code below: (The "joined" is my array of people that have joined the game. This works perfectly)这是我下面的代码:(“加入”是我加入游戏的人的数组。这完美无缺)
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);
}
}
}
})
I've not used discord.js since mid 2019, but back then it would've been自 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)
}
});
I believe, as I said, it's been a while.我相信,正如我所说,已经有一段时间了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.