Open WieeRd opened 10 months ago
I might make this feature a protocol-mixin (trait at home) like SendExt
in #4.
To do that, Webhookable
(or WebhookExt
?) will have to be a Protocol
.
It's more future-proof to more channels types being added in the future as well.
Continuation of the original
GMacLak.wsend()
method in ClockBot v3.Tasks
wsend(to: Webhookable, **options)
without cachingWebhookable
- choose betweenProtocol
orUnion
.wsend()
available to custom contexts as a methodWhat?
Upon invoking
ctx.wsend(content, ...)
, automatically fetch and cache the webhook, and send a webhook message to the target channel with given arguments.The goal is to make the task of sending a webhook message as trivial as normal
.send()
calls.Why?
ClockBot and its cogs frequently need to send webhook messages in various forms. It's tedious to deal with above every time, and without caching it can take up to a few seconds.
How?
wsend()
channel: webhook
mapping)ctx.send_error()
Webhookable
https://discordpy.readthedocs.io/en/stable/search.html?q=channel.webhooks
.webhooks()
and.create_webhook()
are provided for all of themThe goal is to restrict channels that can be used with
wsend()
through type hints.Caching
Simple. It's just
dict[Webhookable, Webhook]
. But where do I store this, and how do I pass it around?