我从上网学的东西,可是有点问题请问是什么问题?

error
File “/home/runner/thx/venv/lib/python3.8/site-packages/dismusic/events.py”, line 6, in module

from discord.ext import commands

bot = commands.Bot(command_prefix="z! ")

bot.lava_nodes = [
  {
    'host': 'lava.link',
    'port': 80,
    'rest_uri': f'http://lava.link:80',
    'identifier': 'MAIN',
    'passaword': 'anything',
    'region': 'singapore'
  }
]

@bot.event
async def on_ready():
  print("Bot is ready to play music.")
  bot.load_extension("dismusic")

bot.run("OTg5MDQwNzAxMzE0NTY0MTM2.GlSmjE.7v47MBGNbE4l-RMWXiMbQEx2rIlNgnr2PU5t7A")

你好,可以发一下具体的链接吗?以及详细描述一下你的问题,谢谢!

Discord music bot in 20 lines of code - YouTube 学习网址

下面的是error

Ignoring exception in on_ready
Traceback (most recent call last):
  File "/home/runner/thx/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 606, in _load_from_module_spec
    spec.loader.exec_module(lib)
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/runner/thx/venv/lib/python3.8/site-packages/dismusic/__init__.py", line 2, in <module>
    from .events import MusicEvents
  File "/home/runner/thx/venv/lib/python3.8/site-packages/dismusic/events.py", line 6, in <module>
    class MusicEvents(commands.Cog, wavelink.WavelinkMixin):
AttributeError: module 'wavelink' has no attribute 'WavelinkMixin'

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

Traceback (most recent call last):
  File "/home/runner/thx/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 19, in on_ready
    bot.load_extension("dismusic")
  File "/home/runner/thx/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 678, in load_extension
    self._load_from_module_spec(spec, name)
  File "/home/runner/thx/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 609, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'dismusic' raised an error: AttributeError: module 'wavelink' has no attribute 'WavelinkMixin'

把完整的代码放到 可以公开访问地方, 如github 或者 gitlab 。方便快速定位问题

应该是异步处理的相关代码没处理好,
希望提供完整的代码

对于初学者,我们在国内的小伙伴往往会陷入各种库的安装,各种镜像的配置,环境变量的配置,由于网络原因好多下载失败的问题。对于初学者或许js就是最好的入门方式。我们不要陷入花大量的时间在网络上找bug的帮助。利用代码写一些网站,写一些交互是更重要的。随着技术的进步,我觉得上面的问题后续解决会很快。

1 Like