VoxelBotUtils
VoxelBotUtils copied to clipboard
async cog setup
To add support for async setups in a cog
async def setup(bot):
n = Foo(bot)
bot.add_cog(n)
await n.initialize() # an async function which needs to be run on cog load, I know we can do bot.loop.create_task but this could be an good add-on
Could be useful while caching something or run some async code when it’s loaded
I'm not against it, but that then means that teardown
as well as load_extension
and remove_extension
need to also be async.
Maybe better (although more suited for VBU) would be a method that gets run when the cog is loaded? Some kind of async init.
I'm just throwing thoughts out there at the moment.
I'm not against it, but that then means that
teardown
as well asload_extension
andremove_extension
need to also be async.Maybe better (although more suited for VBU) would be a method that gets run when the cog is loaded? Some kind of async init.
I'm just throwing thoughts out there at the moment.
async init like we have startup_caching
for db in cog? then its feasible for what I’m trying to do
Wouldn't this break the drop in functionality of dpy cogs to vbu?
Wouldn't this break the drop in functionality of dpy cogs to vbu?
As kae mentioned above, there might be some kind of async init instead of fully async setup and I don't think it'd break functionality of dpy cogs to vbu, there's async setup support for cogs on red-discordbot which I used to use sometime ago, you could do async, and normal setup as you do right now in it.