So I'm having trouble with my Discord Bot in Python.
The code for it became just too much for having a good overview, so I wanted to split it up into different source-files.
(Main-File)
...
import second_file
if message.content.lower().startswith("!Hi"):
second_file.hello()
(Second-File)
...
from __main__ import client
def hello():
await client.send_message(message.channel, "Hiii <3!")
The error I am getting is name "client" is not defined.
What should I do? Thanks :)
Try replacing
from __main__ import clientwithfrom main import clientassuming your main python file is calledmain.py.You need to do this because python wants just the file name when importing another script. I would also recommend changing your main file name to something else as
__main__in python is reserved for other things.