How to receive webhook update gateway events?

Hello, I'm trying to receive webhook events through the code below:
import { Client, Events, GatewayIntentBits } from 'discord.js'

const client = new Client({
intents: [GatewayIntentBits.GuildWebhooks],
})

client.once(Events.ClientReady, (c) => {
console.log('Ready as ', c.user?.tag)
})

client.on(Events.WebhooksUpdate, (c) => {
console.log('webhook update', c)
})

client.login(process.env.BOT_TOKEN)
import { Client, Events, GatewayIntentBits } from 'discord.js'

const client = new Client({
intents: [GatewayIntentBits.GuildWebhooks],
})

client.once(Events.ClientReady, (c) => {
console.log('Ready as ', c.user?.tag)
})

client.on(Events.WebhooksUpdate, (c) => {
console.log('webhook update', c)
})

client.login(process.env.BOT_TOKEN)
I tried - changing a webhook's name - adding/moving a webhook but the only log I get is the initial ready log. The bot has Administrator permission. Is there something wrong with the code snippet above? Version's 14.13.0
5 Replies
d.js toolkit
d.js toolkit16mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna16mo ago
You also need the Guilds intent iirc
S64
S64OP16mo ago
ah that was exactly it. thanks! I'm a bit wary of receiving guild intents though, depending on how much more the client may be doing...do you know if there is any caching that comes with this? ideally I'd like to only receive events, and have no side effects (caching or the sorts)
treble/luna
treble/luna16mo ago
It caches all the guilds, channels and roles If you dont want any caching, you're better off using /core
S64
S64OP16mo ago
I see, that sounds like the better route - thanks, I appreciate the quick help
Want results from more Discord servers?
Add your server