hey, im trying to use py-cord to make a custom help command, but im running into an issue. When i use discord-py everything works fine however when i uninstall it and switch to py-cord it doesnt seem to work. This is the error im getting File "C:\Users\jan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 382, in _run_event await coro(*args, **kwargs) File "C:\Users\jan\Desktop\code\botty.py", line 15, in on_ready await bot.load_extension(f"cogs.{filename[:-3]}") TypeError: object dict can't be used in 'await' expression
#TypeError object dict can't be used in 'await' expression
1 messages · Page 1 of 1 (latest)
remove the await
tried, still same thing
send your new code
also add store=False to load_extension
how are you doing filename part?
def load_cogs():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
bot.load_extension(f"cogs.{filename[:-3]}", store=False)
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity(name="typing races", type=discord.ActivityType.competing, status=discord.Status.idle))
print("Everything's all ready to go!")
load_cogs() ``` when i run this, i get ```
RuntimeWarning: coroutine 'setup'
was never awaited
setup(self)```
and when i keep it in async with await in the @bot.event i get TypeError: object list can't be used in 'await' expression
Can you show the setup in the cog?
class help(commands.Cog, name="Help"):
"""Shows help info for commands and cogs"""
def __init__(self, bot):
self._original_help_command = bot.help_command
bot.help_command = help_cmd()
bot.help_command.cog = self
self.bot = bot
async def setup(bot: commands.Bot):
await bot.add_cog(help(bot))```
Remove the async and the await in the setup
File "C:\Users\jan\Desktop\code\botty.py", line 15, in on_ready
await bot.load_extension(f"cogs.{filename[:-3]}", store=False)
TypeError: object list can't be used in 'await' expression``` still
It should be only
def setup(bot)
bot.add_cog(name(bot))
removed commands.Bot too
i removed the original cog, to see if that was the issue but i guess not, i made a second cog thats really simple ```py
import discord
from discord.ext import commands
class Ping(discord.Cog, name="Ping"):
def init(self, bot):
self.bot = bot
COG_EMOJI = "🏓"
@commands.slash_command(name="ping", description="Ping command", guilds_id=[guildid])
async def ping(self, ctx):
await ctx.send("Pong!")
@commands.slash_command(name="ping2", description="Ping command", guilds_id=[guildid])
async def ping2(self, ctx):
await ctx.send("Pong!")
def setup(bot):
bot.add_cog(Ping(bot))and it still doesnt load the cog
await bot.load_extension(f"cogs.{filename[:-3]}", store=False)
TypeError: object list can't be used in 'await' expression```
okay, but that still doesnt fix the issue of me not being able to LOAD the cogs
this isn't dpy 2.0... they made cog management async
yeah, i already fixed it, just wanted to say that. thanks though
ahok
👉 /close