I want to clean up the code of my Discord bot a little with splitting commands up into different files instead of having just one huge main file. I know that I can "import" code directly from other files simply with import [file], but I fail to make it work with Discord code.
If I try something like:
test1.py
await ctx.send("successful")
main.py
@client.command()
asnyc def test(ctx):
import test1
I always get the error SyntaxError: 'await' outside function. I know that it's because the await is outside any async function, but I don't know how to fix it. If I replace test1.py with something like print("successful"), it prints the correct response to console. I tried looking solutions up already but am rather getting more and more confused by it.