Code (most of it is hidden):
import discord
from discord import app_commands
from discord.ext import commands
intents = discord.Intents.default()
bot = discord.Client(
intents=intents,
description='REDACTED',
case_insensitive=True,
owner_id=REDACTED
)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name} - {bot.user.id}')
bot.load_extension(cogs.Mod)
bot.run("token")
Error:
Traceback (most recent call last):
File "C:\Users\Personal\discord-bots\quantum.py\quantum.py", line 18, in <module>
bot.load_extension(cogs.Mod)
^^^^^^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'load_extension'
I was trying to be able to use the <bot/client>.load_<extension/cog>() prompt, but it didn’t work all of a sudden.
>Solution :
On the current version of discord.py (2.1.0), you can only call load_extension on a discord.ext.commands.Bot (see https://discordpy.readthedocs.io/en/stable/ext/commands/api.html?highlight=load_extension#discord.ext.commands.Bot.load_extension)
As per the API documentation:
This class is a subclass of discord.Client and as a result anything that you can do with a discord.Client you can do with this bot.
So you shouldn’t have any trouble replacing discord.Client with a commands.Bot in your existing code.