Failed to load ping: 'client' object has no attribute 'load_extension' #9305
Answered
by
LeoCx1000
NavisGames
asked this question in
Q&A
-
Hello! I got a cog with setup and everything else, now i got a client and i want to add the cog, now it says the error in the title, how can i fix that? class client(discord.Client):
def __init__(self, intents=discord.Intents.all()):
super().__init__(intents=discord.Intents.all())
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync()
self.synced = True
await self.change_presence(
activity=discord.Activity(
type=discord.ActivityType.playing,
name=f"SIGMA | /help | {len(self.guilds)}",
),
)
print(f"Bot started! {self.user} (ID: {self.user.id})")
aclient = client()
tree = app_commands.CommandTree(aclient)
for file in os.listdir("./cogs"):
if file.endswith(".py"):
await aclient.load_extention(f"cogs.{file[:-3]}") |
Beta Was this translation helpful? Give feedback.
Answered by
LeoCx1000
Mar 17, 2023
Replies: 1 comment 11 replies
-
discord.Client does not have extensions or cogs. You need to use commands.Bot for that functionality. Also, awaiting something must be done within an async function. You can use the |
Beta Was this translation helpful? Give feedback.
11 replies
Answer selected by
NavisGames
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
discord.Client does not have extensions or cogs. You need to use commands.Bot for that functionality.
Also, awaiting something must be done within an async function. You can use the
setup_hook
of your Bot subclass. And you should sync tree insidesetup_hook
too, rather thanon_ready
, since the former only triggers once and you would not need you to useself.synced
.