Bot is not finding file and says runtimewarning

How i can fix this? i keep getting this runtimewarning and when I type ?help in discord bot says that command not found.
Error: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Repl link:

import os

import discord
from discord.ext import commands

from import Help
from keep_alive import keep_alive


bot = commands.Bot(
  command_prefix="?", case_insensitive=True, intents=discord.Intents.all()

async def on_ready():
  print(f"Logged in as {}")
  print(f"Bot ID: {}")
  await bot.wait_until_ready()
    print("Cog 'help' loaded successfully!")
  except Exception as e:
    print(f"Failed to load cog 'help': {e}")

async def on_command_error(ctx, error):
  if isinstance(error, commands.errors.CommandNotFound):
    await ctx.send(
      "The command you specified was not found. Type ?help to see all available"
      " commands."

  elif isinstance(error, commands.MissingRequiredArgument):
    await ctx.send("You are missing a required argument.")

  elif isinstance(error, commands.errors.MissingPermissions) or isinstance(
    error, discord.Forbidden
    await ctx.send("Sorry. You don't have the permission for that command.")

  elif isinstance(error, commands.errors.CommandOnCooldown):
    if == "report":
      await ctx.message.delete()
        f"""Sorry, but we have made a cooldown to prevent the abuse of the command. Try again in {error.retry_after:,.2f} seconds.
If you want to report something before the cooldown is over or you made a report on accident then please contact a staff member and we will get it sorted out."""
      await ctx.send(
        f"You need to wait {error.retry_after:,.2f} seconds before trying this"
        " command again."

  elif isinstance(error, commands.errors.MissingRole):
    if in [""]:
      await ctx.send("You need premium to use this command")

    await ctx.send(f"An error occurred: {error}")["token"])

The error is saying that you must await bot.load_extension. Since you’re already inside an async function (on_ready event) you just need to add the await keyword.

    await bot.load_extension("")  # Add the await before the bot.load

Not working. Im still getting same runtimewarning

Can you show the full error message?

Okay, it seems I just got new error. Idk if my friend did something to code but now its saying this

You just need to change the port in this case, or even better, just let that Replit assign the port and erase the part where you specify the port in your code.

def run():'')

Can you get the full error message?

From the looks of it there seems to be no problem at all with the code.

Only error what i get is “failed to load cog…”

Since there is no traceback information I think it would be better you start configure logging into your application. Import the logging configuration in your

import logging

And configure the logging level

logging.basicConfig(level=logging.INFO, format='%(asctime)s:%(levelname)s:%(name)s: %(message)s')

And the logging events in your on_ready

async def on_ready():'Logged in as {} (ID: {})') #add this line
    #  the rest of your code
1 Like

Can you try test the bot without loading the ‘help’ cog to see if the error persists?

I removed it and no error. So problem is in import cog

So what should i do @WindLother?

Erase this part from your

def setup(bot):

And change your a little

import os
import logging
import sys
import traceback  # Since is not gerenerating any traceback import his so we can know the full error

import discord
from discord.ext import commands

from keep_alive import keep_alive

# Try add a list of cogs to be loaded (add this after all your events, before the def setup(bot)
initial_extensions = [

if __name__ == "__main__":
    # Then load the cogs here
    for extension in initial_extensions:
        except Exception as e:
            print(f"Failed to load extension {extension}.", file=sys.stderr)
            traceback.print_exc()  # This will print the full traceback
    keep_alive()  # And move the keep_alive() to here["token"])

And remove all this part from your on_ready event:

    await bot.load_extension("")
    print("Cog 'help' loaded successfully!")
  except Exception as e:
    print(f"Failed to load cog 'help': {e}"

So the on_ready() event will look like this:

async def on_ready():'Logged in as {} (ID: {})')
    print(f'Logged in as {}')
    print(f'Bot ID: {}')
    await bot.change_presence(activity=discord.Game(name="COMMANDS OFFLINE"))

Try this changes and let me know.

Says this same error for every file.

I think I just did some simple mistake with bot function but idk

You did not insert the code in the order I told you. The part I told you to include goes to the bottom part after youir whole code and before the["token"]).

Oh sorry, I read your instruction wrong. I think I now did it right and got once again runtime warning + error in the image. Bot still saying that cmd not found.

Sry, im dump with cogs. But I dont want to give up with this