Question:
async def function calls work perfectly fine locally and I have a few async calls in my Replit, but as soon as I updated the cogs to reflect the change in the Discord API requiring cogs be run using async def
instead of def
and await bot.add_cog
instead of bot.add_cog
it won’t work in Replit.
Repl link:
https://replit.com/@LyndenSylver/DiscordBot
Here’s a very simple example:
Locally this works:
import discord
from discord.ext import commands
class Test(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def test(self, ctx):
await ctx.send("test passed!")
print("Test passed!")
async def setup(bot):
await bot.add_cog(Test(bot))
This is the console log I get:
Failed to load cog cogs.currency: object NoneType can't be used in 'await' expression
Failed to load cog cogs.customhelp: object NoneType can't be used in 'await' expression
Failed to load cog cogs.dev: object NoneType can't be used in 'await' expression
Failed to load cog cogs.devtools: object NoneType can't be used in 'await' expression
Failed to load cog cogs.economy: object NoneType can't be used in 'await' expression
Failed to load cog cogs.games: object NoneType can't be used in 'await' expression
Failed to load cog cogs.login: object NoneType can't be used in 'await' expression
Failed to load cog cogs.media: object NoneType can't be used in 'await' expression
Failed to load cog cogs.settings: object NoneType can't be used in 'await' expression
Failed to load cog cogs.shops: object NoneType can't be used in 'await' expression
Failed to load cog cogs.support: object NoneType can't be used in 'await' expression
Failed to load cog cogs.time: object NoneType can't be used in 'await' expression
Failed to load cog cogs.user: object NoneType can't be used in 'await' expression
All the cogs seemed to work fine in Replit when it was this structure:
def setup(bot):
bot.add_cog(Cogname(bot))
Not sure why async doesn’t work