Discord.js #39;presenceUpdate#39; not being called(Discord.js presenceUpdate 没有被调用)
问题描述
我有一个特殊用户";这等于'Client.users.fetch(Special User's ID)'.然后用户有两个事件监听器附加到它,'message'和'presenceUpdate',消息事件监听器工作完美,虽然 presentUpdate 根本不起作用,非常感谢所有帮助!
require("dotenv").config();const Discord = require(`discord.js`);const Client = new Discord.Client();Client.on("准备好", () => {console.log(` Client 就绪`);});var SpecialUser = Client.users.fetch(进程.env.ID).then((用户) => {控制台.log(用户名);//在职的User.client.addListener("message", (message) => {console.log(消息");});//不工作User.client.addListener("presenceUpdate", (Old, New) => {console.log(`状态更新`);});}).catch(console.error);Client.on("message", (message) => {});Client.login(process.env.TOKEN);
如果 presenceUpdate
事件没有触发,你可能需要添加 GUILD_PRESENCES
意图使用
I have a "Special User" which is equal to 'Client.users.fetch(Special User's ID)'. Then the user has two event listeners attached to the it, 'message' and 'presenceUpdate', The message event listener works perfects, although the presenceUpdate does not work at all, All help is greatly appreciated!
require("dotenv").config();
const Discord = require(`discord.js`);
const Client = new Discord.Client();
Client.on("ready", () => {
console.log(` Client Ready`);
});
var SpecialUser = Client.users
.fetch(process.env.ID)
.then((User) => {
console.log(User.username);
// Working
User.client.addListener("message", (message) => {
console.log("message");
});
// Not Working
User.client.addListener("presenceUpdate", (Old, New) => {
console.log(`Presence Updated`);
});
})
.catch(console.error);
Client.on("message", (message) => {});
Client.login(process.env.TOKEN);
If the presenceUpdate
event doesn't trigger, chances are you'll need to add the GUILD_PRESENCES
intent either using the client options:
const Discord = require(`discord.js`);
const client = new Discord.Client({
intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_PRESENCES'],
});
// rest of your code...
In your Discord dashboard; by choosing your bot then by clicking on the Bot
settings:
这篇关于Discord.js 'presenceUpdate' 没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Discord.js 'presenceUpdate' 没有被调用


基础教程推荐
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01