我想检查是否agrs[1]是会员名。我目前使用的代码:const Discord = require ('discord.js')const client = new Discord.Client() const PREFIX = "!"; client.on('ready', () => { console.log('connect as ' + client.user.tag) let guild = client.guilds.get('636639114787291137')})client.on('message', message =>{ let agrs = message.content.substring(PREFIX.length).split(" "); switch (agrs[0]){ case 'teammate': if (!agrs[1]) { return message.reply("enter a member after !teammate") } else { message.reply(agrs[1]) } break; }})client.login("xxx")
2 回答
翻阅古今
TA贡献1780条经验 获得超5个赞
你可以用
let guild = client.guilds.get(message.guild);
const user = message.mentions.users.first();
const userID = user.id;
if (guild.member(userID)) {
console.log("That is a correct mention");
}
holdtom
TA贡献1805条经验 获得超10个赞
你可以用
message.mentions.members.first()
这将返回消息中提到的第一个成员。
文档:Message , Mentions , GuildMember , Collection
添加回答
举报
0/150
提交
取消