Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从提及中查找用户(Discord.js、斜杠命令)_Javascript_Node.js_Discord.js - Fatal编程技术网

Javascript 从提及中查找用户(Discord.js、斜杠命令)

Javascript 从提及中查找用户(Discord.js、斜杠命令),javascript,node.js,discord.js,Javascript,Node.js,Discord.js,我基本上有一个价值,我希望我的机器人在我的公会中找到那个用户。我正试图用斜杠命令来做这件事 //This gets the guild that the slash command was used in const guild = bot.guilds.cache.get(interaction.guild_id) //This is for example, the content from the slash command would be like this let value =

我基本上有一个价值,我希望我的机器人在我的公会中找到那个用户。我正试图用斜杠命令来做这件事

//This gets the guild that the slash command was used in
const guild = bot.guilds.cache.get(interaction.guild_id)

//This is for example, the content from the slash command would be like this
let value = `<@!123456789012345678>`

//I tried this but it doesn't work
//This is what I need to know
let userR = guild.members.cache.find(member => member === value)
//这将获取使用斜杠命令的公会
const guild=bot.guilds.cache.get(interaction.guild\u id)
//例如,slash命令的内容如下
let值=``
//我试过了,但没用
//这就是我需要知道的
让userR=guild.members.cache.find(member=>member==value)

如果有人知道怎么做,请让我知道。谢谢(而且我刚得到stackoverflow,所以我是一个新手)

通过正则表达式从提及中提取id,然后使用
guild.members.cache.get(id)
好的,我会试试。我在尝试让正则表达式工作时遇到了问题,但我只需用“`”替换即可。但是谢谢你的帮助!