【发布时间】:2022-01-12 05:13:58
【问题描述】:
我的 discord.js 文件中有一个命令,允许用户使用 !vote @user 命令为某人投票。每当我打印出@user 时,我都会得到<@!user_id>。有没有办法将该值转换为可操作的东西,例如,获取@users 的用户名或在语音通话中将其静音,例如使用msg.user 时?
client.on('message', msg) {
if (msg.content.startsWith('!')) {
let command = msg.content.substring('!'.length);
let ping = command.split(' ');
if(command == 'vote') {
// Convert <@!user_id> into a manipulatable user?
let user_information = ping[1]
}
}
}
【问题讨论】:
-
也许你可以看看
<Message>.mentions.users.first()? discord.js.org/#/docs/main/stable/class/…
标签: javascript node.js discord discord.js