在 discord.js v13 Slash 命令中通过 UserId 获取 GuildMember
Get GuildMember by UserId in discord.js v13 Slash Command
到目前为止我已经搜索了很多资料,但找不到任何有效的代码。你能告诉我你得到的代码吗?
这就是我注册 Slash Command 的方式。
client.api.applications(client.user.id).guilds(guild).commands.post({
data: {
name: command.name,
description: command.description,
options: command.options
}
});
我是韩国人,所以我写了一个翻译器。
要获取运行斜线命令用户的GuidMember
details of the user by the user's id, you would first have to fetch the guild id, then you can use client.guilds.cache.get(guildid).members.cache.get(userid)
. But since you are doing this in a slash command, you would receive an Interaction
object when the user uses the slash command, so then you can just use interaction.guild.members.cache.get(userid)
. If you want to get the GuildMember
详细信息,那么你可以只使用const guildmember = interaction.member
到目前为止我已经搜索了很多资料,但找不到任何有效的代码。你能告诉我你得到的代码吗? 这就是我注册 Slash Command 的方式。
client.api.applications(client.user.id).guilds(guild).commands.post({
data: {
name: command.name,
description: command.description,
options: command.options
}
});
我是韩国人,所以我写了一个翻译器。
要获取运行斜线命令用户的GuidMember
details of the user by the user's id, you would first have to fetch the guild id, then you can use client.guilds.cache.get(guildid).members.cache.get(userid)
. But since you are doing this in a slash command, you would receive an Interaction
object when the user uses the slash command, so then you can just use interaction.guild.members.cache.get(userid)
. If you want to get the GuildMember
详细信息,那么你可以只使用const guildmember = interaction.member