0

I'm try to import my main python file but it's not working.

import discord
from discord.ext import commands
from ..bot import bot
class help(commands.Cog):
    
    def __init__(self, client):
        self.client = client
    @commands.command(name="help", aliases=["Help"])
    async def help(self,context, message = None):
        embed = discord.Embed(title="Help command")
        cmds = ""
        if message == None:
            bot.listcom(cmds)
            embed.add_field(name="Commands", value=cmds)
        if not message == None:
            pass
        await context.send(embed=embed)

def setup(client):
    client.add_cog(help(client))

Terminal Output:

ImportError: attempted relative import with no known parent package

I tried using import ..bot but it gave a syntax error and when I tried using just import bot it said it didn't exist. Can somebody help me?

rlp81
  • 9
  • 3

1 Answers1

0

https://stackoverflow.com/a/24868877/16237426
found that..

in your case that should work:

import sys, os
sys.path.append(os.path.abspath(os.path.join('..')))
from bot import bot
MeroFuruya
  • 20
  • 5