Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make load_extention able to some options #7394

Open
sevenc-nanashi opened this issue Aug 14, 2021 · 4 comments
Open

Make load_extention able to some options #7394

sevenc-nanashi opened this issue Aug 14, 2021 · 4 comments
Labels
feature request This is a feature request.

Comments

@sevenc-nanashi
Copy link
Contributor

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.

@sevenc-nanashi sevenc-nanashi added the feature request This is a feature request. label Aug 14, 2021
@SebbyLaw
Copy link
Contributor

See #5839.

@nitori
Copy link

nitori commented Aug 21, 2021

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.

@mwobat
Copy link
Contributor

mwobat commented Apr 23, 2022

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): ...

@DanielBaulig
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request This is a feature request.
Projects
None yet
Development

No branches or pull requests

5 participants