Bot.load_Extension is returning this error for disnake and discord.py library both

19 Views Asked by At
/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

This is my redis.py I don't understand why this is happening there is nothing that can be Nonetype here I guess. redis.py



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)

I tried it with discord.py using bot.load_extension("cogz,redis"), but I am still getting the same error.

0

There are 0 best solutions below