Эта ошибка возникает при загрузке файла main.py:
Код: Выделить всё
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.cog' raised an error: TypeError: object NoneType can't be used in 'await' expression
Код: Выделить всё
# Cogs
async def load_extensions():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
# cut off the .py from the file name
await bot.load_extension(f"cogs.{filename[:-3]}")
async def main():
async with bot:
await load_extensions()
await bot.start(os.getenv('TOKEN'))
asyncio.run(main())
Код: Выделить всё
import os, discord
from discord.ext import commands
class Test(commands.Cog):
def __init__(self, client):
self.client = client # sets the client variable so we can use it in cogs
self.intents = discord.Intents.default()
self.intents.message_content = True
@commands.command()
async def command(self, ctx):
await ctx.send("Yes?")
def setup(client):
client.add_cog(Test(client, ))
Подробнее здесь: https://stackoverflow.com/questions/754 ... -discord-p