Search code examples
pythondiscorddiscord.pynextcordpositional-argument

Node.is_connected() missing 1 required positional argument: 'self'


I want to create my music bot using wavelink module (nextcord, Python). Everything is fine, but I have 1 problem. When I create a Node, after some time host may break down or change its port. So I create a list with different hosts, ports and etc. to connect to if previouse host isn't work, and for that I need to know if Node is connected. I check the docs for wavelink and find wavelink.Node.is_connected() function, but I get this error:

TypeError: Node.is_connected() missing 1 required positional argument: 'self'

Does anyone know how to solve this problem? Here is my code:

@client.event
async def on_ready():
    print("Bot is online!")
    client.loop.create_task(node_connect())

@client.event
async def node_connect():
    await client.wait_until_ready()
    hosts = ["list"]
    values = np.random.choice(hosts)
    print(values)
    host = values["host"]
    port = values["port"]
    password = values["password"]
    https = values["secure"]

    await wavelink.NodePool.create_node(bot = client, host = host, port = port, password = password, https = https)

    await wavelink.Node.is_connected()

@client.event
async def on_wavelink_node_ready(node: wavelink.Node):
    print(f"Node {node.identifier} is ready!")

Solution

  • X.y() missing 1 required positional argument: self is generally a symptom of trying to call an instance method directly on a class without passing in the instance.

    Presumably, create_node returns the node, so you'd call the function on it:

    node = await wavelink.NodePool.create_node(bot=client, ...)
    await node.is_connected()