Hydra
Hydra

Reputation: 1

__init__() missing 1 required positional argument: 'config'

This is my Code for Music Command I get this error Mentioned Above Can anyone Help Me Out ?

class Music(commands.Cog):
    """Bot commands to help play music."""

    def __init__(self, bot, config):
        self.bot = bot
        self.config = config[__name__.split(".")[
            -1]]  # retrieve module name, find config entry
        self.states = {}
        self.bot.add_listener(self.on_reaction_add, "on_reaction_add")

Upvotes: 0

Views: 1350

Answers (1)

Deera Wijesundara
Deera Wijesundara

Reputation: 771

This likely happened because you did something like

a = Music(something)

And forgot to enter something for config. To solve this you could give config some default value so something like,

class Music(commands.Cog):

    def __init__(self, bot, config='some default thing'):
        self.bot = bot
        self.config = config[__name__.split(".")[
            -1]]  # retrieve module name, find config entry
        self.states = {}
        self.bot.add_listener(self.on_reaction_add, "on_reaction_add")

Or if config is required you could put something for config on the line that you called it, So using a = Music(something,something_else) instead of a = Music(something)

Upvotes: 1

Related Questions