hikari-py/hikari

Webhook cacheing

HazemMeqdad opened this issue · 1 comments

Summary

Add a bot.cache.get_webhooks_for_channel()

Why is this needed?

if you use a send with webhook, you got rate limit because fetch it :

Ideal implementation

on fetch any webook caching saved it, and on not found delete it from cache

Checklist

  • I have searched the issue tracker and have made sure it's not a duplicate. If it is a follow up of another issue, I have specified it.

Webhooks are not part of the channel object. They would have to be obtained through other means (in your case, REST API).

There is also no way to know when webhooks are created/deleted as there are no events for it. This makes this impossible to keep a consistent cache for them. Thus, there is no way for this to be implemented.


I would recommend you fetch the webhooks and store them yourself in a mapping to prevent getting ratelimited. If you rely on a specific webhook to use, I suggest storing it in a mapping and creating/fetching a new one when you can't execute the one you have anymore

ref: https://discord.com/developers/docs/resources/channel#channel-object