0

trying to make a discord bot with a port scanner and keep running into this error

async def scan(ctx):
    async def scan(port):
            try:
                s = socket.socket()
                s.settimeout(1)
                s.connect((ip, port))
                s.close()
                with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:
                    for port in range(65500):
                        executor.submit(scan, ip, port + 1)
                        client.run(TOKEN)```

the error is                                                                              

 File "bot.py", line 94

                           ^
SyntaxError: unexpected EOF while parsing
Iam Loupes
  • 11
  • 2
  • When posting syntax errors something is wrong with the syntax of your code. You should send the whole code so we know which line `line 94` corresponds to. I can see 2 syntax mistakes: 1. wrong indentation 2. `\`\`\`` random backticks. – Tin Nguyen Jan 19 '21 at 08:23

1 Answers1

1

a try block needs a following except block. add this to your code to make it work:

except:
    pass

or you could just remove the try block entirely, both solutions work. Here's what the error means

from this answer:

The SyntaxError: unexpected EOF while parsing means that the end of your source code was reached before all code blocks were completed. A code block starts with a statement like for i in range(100): and requires at least one line afterwards that contains code that should be in it.

nonimportant
  • 406
  • 4
  • 15