我正在尝试为我的名为Timer Bot的机器人记录状态。我希望它能在他上线和下线的时候提醒每个人。这是我正在使用的脚本-
client.on('presenceUpdate', (oldPresence, newPresence) => {
let member = newPresence.member;
// User id of the user you're tracking status.
if (member.id === '603517534720753686') {
if (oldPresence.status !== newPresence.status) {
// Your specific channel to send a message in.
let channel = member.guild.channels.cache.get('788547135234375712');
// You can also use member.guild.channels.resolve('<channelId>');
let text = "";
if (newPresence.status === "online") {
text = "**Hello @everyone, Timer Bot is now online! Thank you for your patience.**";
} else if (newPresence.status === "offline") {
text = "**@everyone Due to issues, Timer Bot is currently offline. We apologize for the inconvenience.**";
}
// etc...
channel.send(text);
}
}
});由于某些原因,它不能工作。有人知道为什么吗?谢谢,Brian.#1111
发布于 2020-12-16 07:45:49
您需要启用在线状态意图,然后在登录时将其传递给客户端。


new Discord.Client({ws:{intents: [Intents.FLAGS.GUILD_PRESENCES]}});来源:https://discord.js.org/#/docs/main/stable/class/Intents?scrollTo=s-FLAGS https://discord.com/developers/applications/
https://stackoverflow.com/questions/65315270
复制相似问题