Discord.js-除Bot用户更改外不调用guildMemberUpdate [英] Discord.js - guildMemberUpdate not being called except on Bot user changes
问题描述
使用以下代码,除了bot用户以外,guildMemberUpdate事件根本不需要任何用户修改.是什么原因导致了此更改,以及如何解决此问题?
VSC,最新安装了discord.js的npm.也启用了Discord上的网关意图.
client.on('guildMemberUpdate',(oldMember,newMember)=> {//如果用户具有角色则触发如果(newMember.roles.cache.some(r => r.name ==="TEST_ROLE")){尝试 {//东西} catch(err){//东西}}})
您似乎没有启用公会成员意图!要启用,请转到:
With the following code, the guildMemberUpdate event does not call for any user modification at all except for the bot user. What could have caused this change, and how do I troubleshoot this?
VSC with latest npm install of discord.js. Enabled the gateway intents on Discord, too.
client.on('guildMemberUpdate', (oldMember, newMember) => {
// Fire if user has a role
if (newMember.roles.cache.some(r => r.name === "TEST_ROLE")) {
try {
// stuff
} catch(err) {
// stuff
}
}
})
It looks like you did not enable Guild Members Intent! To enable, go to: https://discord.com/developers/applications
Now click on your bot application.
Click on "Bot" on the left panel.
Scroll down until you see "Privileged Gateway Intents".
Below that are two toggles.
Toggle "Guild Members Intent" and save.
Hoped this helped you!
Further reading: https://discord.com/developers/docs/topics/gateway
这篇关于Discord.js-除Bot用户更改外不调用guildMemberUpdate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!