devoxin / Lavalink.py

A wrapper for Lavalink in Python, which aims to be powerful and intuitive.
https://lavalink.readthedocs.io/
MIT License
224 stars 95 forks source link

Failed to load Cogs.music #106

Closed FeelsBadMan1 closed 3 years ago

FeelsBadMan1 commented 3 years ago

Hello, i used the examplecode but then i get an nonetype error that i dont know how to solve:

Failed to load extension music.py
Traceback (most recent call last):
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord\ext\commands\bot.py", line 618, in _load_from_module_spec
    setup(self)
  File "D:\my_python_projects\MongoDB Test\Cogs\music.py", line 175, in setup
    bot.add_cog(Music(bot))
  File "D:\my_python_projects\MongoDB Test\Cogs\music.py", line 22, in __init__
    bot.lavalink = lavalink.Client(bot.user.id)
AttributeError: 'NoneType' object has no attribute 'id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:/my_python_projects/MongoDB Test/mongosetup.py", line 145, in <module>
    bot.load_extension(f"Cogs.{filename[:-3]}")
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
    self._load_from_module_spec(spec, name)
  File "D:\Downloads\Python\python 3.8.7\lib\site-packages\discord\ext\commands\bot.py", line 623, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'Cogs.music' raised an error: AttributeError: 'NoneType' object has no attribute 'id'
apex2504 commented 3 years ago

this is answered in the FAQ channel in the discord server. either hardcode the ID or wait until the bot is ready before loading your cog.

FeelsBadMan1 commented 3 years ago

ah thanks it solved it