【发布时间】:2022-02-01 20:46:19
【问题描述】:
过去几天我一直在进行研究,但实际上找不到任何东西。在 python 中也是如此。
const Discord = require("discord.js")
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })
const member = client.guilds.cache.get("person_id") // person I want to check
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on("message", msg => {
if (msg.content === "ping") {
msg.reply("pong");
}
}) // everything worked to this moment
client.on("presenceUpdate", () => {
if (member.presence.status === 'online') {
client.channels.cache.get("channel_id").send("HELLO"); // message i want bot send to the channel if member goes online
}
});
client.login('***')
如果我添加 GUILD_PRESENCES 意图,我会收到以下错误:
if (member.presence.status === 'online') {
^ TypeError: Cannot read properties of undefined (reading 'presence')
【问题讨论】:
-
代码看起来不错,但我认为需要
GUILD_PRESENCES意图。 -
好吧,现在机器人理论上可以工作,但是当状态改变时我得到一个错误:if (member.presence.status === 'online') { ^ TypeError: Cannot read properties of undefined (reading '存在')
标签: javascript discord discord.js bots