I am trying to load a cog (located in the cogs directory) but everytime I try to load it I get the following error message:
discord.errors.ExtensionFailed: Extension 'cogs.cmds' raised an error: AttributeError: 'Bot' object has no attribute 'add_command'
I'm doing exacly how the tutorial shows, but it still doesn't work. Here is my code:
# main.py
import discord, os, dotenv
# setup
bot = discord.Bot(
intents = discord.Intents.default(),
prefix = "zrun "
)
@bot.event
async def on_ready():
print(f'Connected as {bot.user}')
# load cmds
bot.load_extension('cogs.cmds')
# get token and run bot
dotenv.load_dotenv()
bot.run(os.getenv('TOKEN'))
The cog file:
# cogs/cmds.py
import discord
from discord.ext import commands
class Cmds(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def echo(self, ctx, msg:str):
"""Sends the specified text in the chat"""
await ctx.send(msg)
def setup(bot):
bot.add_cog(Cmds(bot))
Yes, I've searched StackOveflow, but no cog-related answers solved my problem.