Bot.load_Extension在disnake和discord.py库中都返回此错误

0 投票
0 回答
16 浏览
提问于 2025-04-11 21:54
/home/runner/BattleEx/.pythonlibs/lib/python3.10/site-packages/disnake/ext/commands/common_bot_base.py:464: RuntimeWarning: coroutine 'setup' was never awaited
  setup(self)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/home/runner/BattleEx/.pythonlibs/lib/python3.10/site-packages/disnake/client.py", line 703, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/BattleEx/main.py", line 13, in on_ready
    await bot.load_extensions("cogz")
TypeError: object NoneType can't be used in 'await' expression

这是我的redis.py文件。我不明白为什么会出现这个问题,我觉得这里没有任何东西会是None类型。



import aioredis,asyncio
from disnake.ext import commands
import os

from disnake.ext import commands 
import os


class Redis(commands.Cog):
    """For Redis."""

    def __init__(self, bot: commands.Bot):
        self.bot = bot
        self.pool = None
        self._reconnect_task = self.bot.loop.create_task(self.connect())

    #all funcs here

async def setup(bot: commands.Bot):
  print("Here")
  redis_cog = Redis(bot)
  print("Setting up Redis cog...")
  await redis_cog.connect()

  await bot.add_cog(redis_cog)

我试着用discord.py来加载扩展,使用了bot.load_extension("cogz,redis"),但我还是遇到了同样的错误。

0 个回答

暂无回答

撰写回答