Detect when bot webhook has moved to another channel

I'm looking to use webhooks to send messages to specific channels in a guild. Unfortunately, Discord provides no way to stop server admins from moving app-created webhooks to other channels. The webhooksUpdate event is not a great solution on its own— it doesn't tell you the change that was made, or even which webhook was updated, only the channel which may contain other webhooks besides the bot's. It seems like to use this event for this purpose, you'd need to fetch the channel's webhooks (or fetch that specific webhook) to see if it has changed. An alternative if the bot has View Audit Logs permissions could be guildAuditLogEntryCreate, this event should provide the necessary information without having to request from rest. However, it's always possible that the bot may not have access to audit logs. I was just wondering if anyone else has a similar use case to mine, and what other solutions they may have in place 🙂
2 Replies
d.js toolkit
d.js toolkit8mo 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
nick.
nick.OP8mo ago
I was looking to see if I could possibly eliminate the second rest request. My current solution looks something like this: fetch the webhook using its id and token, if it's the expected channel use it, otherwise make a new one and use it I would've liked to have gotten rid of that fetch if possible How would it be worse if they moved another webhook into it? Do you mean if it was a channel that didn’t have one before but they moved one into it? Or if there’d be 2? Afaik you would be able to with the audit log entry create event, that just requires a separate permission I guess fetching all of them at the channel level would make things easier in the case that a webhook was moved into a channel that didn’t have one before
Want results from more Discord servers?
Add your server