discord.py
discord.py copied to clipboard
Make load_extention able to some options
Summary
If load_extension has kwargs for setup command, it'll be so good
What is the feature request for?
discord.ext.commands
The Problem
Currently load_extension cannot pass options, so it's so hard to Config extensions. But if can pass some arguments for setup, it makes extension more customizable.
The Ideal Solution
bot.load_extension("myextension", option1="A")
def setup(bot, option1):
bot.add_cog(MyCog(bot, option1))
The Current Solution
environment variable, add attribute to bot class?
Additional Context
I'm not native of English so this issue may be weird.
See #5839.
Then instead of arbitrary keyword arguments, a single optional data
argument, that can be passed to the setup function if present. Would keep the signature clean.
Then instead of arbitrary keyword arguments, a single optional
data
argument, that can be passed to the setup function if present. Would keep the signature clean.
Or pass the options as keyword-arguments. This would also allow just ignoring options you don't need in the current file.
E.g. in one extension file:
async def setup(bot: commands.Bot, *, my_option: int, **kwargs): ...
And in another file:
async def setup(bot: commands.Bot, **kwargs): ...
Curious if here has been any progress on providing a canonical way to pass arguments and/or configuration from load_extension to the extensions setup call?
What would be the recommended way of doing so? Extending Bot?