問題描述
我有一個特殊用戶";這等于'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' 沒有被調用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!