我正在尝试设置该命令,以便每当机器人接收到来自用户的直接消息时,它都会检查该用户是否在该特定服务器中。
我有服务器的ID,但无法使其工作。
let serverID = "redacted"
let checkGuild = client.guilds.cache.get(serverID)
let checkID = msg.author.id
if (checkGuild.members.cache.find(checkID)){
}else{
msg.reply("Not In Server:ERROR")
}
使用.get()
let guildID = "GUILD_ID"
let userID = "USER_ID"
let guild = client.guilds.cache.get(guildID)
let member = guild.members.cache.get(userID)
if (!member) return message.reply("He left the server")
// Will return undefined if member does not exist