Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

@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()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading