пытаюсь сделать загрузчик винтиков doscord.py

#python-3.x #discord.py

Вопрос:

Я пытаюсь создать команду, которая загрузит определенные винтики из папки cog. Я следил за учебником на YouTube https://youtu.be/vQw8cFfZPx0 но я получаю некоторые ошибки, и я не знаю, как это исправить

 import discord
import os
from discord.ext import commands

client = commands.Bot(command_prefix= "#")

@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f"cogs.{extension}")

@client.command
async def reload(ctx, extension):
    client.reload_extension(f"cogs.{extension}") 

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')

client.run('token')
 

а это мое личное дело

 import discord
from discord.ext import commands

class Example(commands.cog):
    
    def __init__(self, client):
        self.client = client

    #event
    @commands.Cog.listener()
    async def on_ready(self):
        print("bot is online")

    @commands.command()
    async def ping(self, ctx):
        await ctx.send("pong")      



def setup(client):
    client.add_cog(Example(client))  
 

и это та ошибка, которую я получаю

 Traceback (most recent call last):
  File "c:Users...Discord botcogsping.py", line 4, in <module>
    class Example(commands.cog):
TypeError: module() takes at most 2 arguments (3 given)
 

кстати, я новичок в python, поэтому, возможно, совершил очень глупую ошибку

Комментарии:

1. Я считаю, что стоит открыть проблему в проекте CPython для этого сообщения об ошибке. Это бесполезно.

Ответ №1:

Так Cog как это класс, и классы используют соглашение о заглавных словах:

 class Example(commands.Cog):  # instead of class Example(commands.cog):
 

Ответ №2:

commands.cog должно быть commands.Cog

Винтик c in должен быть заглавным