Forums

Setup discord

I created a bot script for discord with python. i installed python 3.6.5 in pc and i opened with CMD its running fine. but i created account here uploaded script and installed discord module. but when i run that script it shows

async def on_message(message): syntax error near unexpected token `('

It looks like you're running it in the wrong version of Python. How are you executing your script?

12:49 ~ $ python DiscordBot.py File "DiscordBot.py", line 8 async def on_message(message): ^ SyntaxError: invalid syntax

i opened bash and typed : $ python DiscordBot.py i got above error so i used python 3.6 code. again i got some error like below one.

12:49 ~ $ python3.6 DiscordBot.py Traceback (most recent call last): File "/home/Demotry/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 601, in _create_direct_connection local_addr=self._local_addr) File "/usr/lib/python3.6/asyncio/base_events.py", line 776, in create_connection raise exceptions[0] File "/usr/lib/python3.6/asyncio/base_events.py", line 763, in create_connection yield from self.sock_connect(sock, address) File "/usr/lib/python3.6/asyncio/selector_events.py", line 451, in sock_connect return (yield from fut) File "/usr/lib/python3.6/asyncio/selector_events.py", line 481, in _sock_connect_cb raise OSError(err, 'Connect call failed %s' % (address,)) ConnectionRefusedError: [Errno 111] Connect call failed ('201.21.88.65', 443) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/Demotry/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 304, in connect yield from self._create_connection(req) File "/home/Demotry/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 578, in _create_connection transport, proto = yield from self._create_direct_connection(req) File "/home/Demotry/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 624, in _create_direct_connection (req.host, req.port, exc.strerror)) from exc aiohttp.errors.ClientOSError: [Errno 111] Can not connect to discordapp.com:443 [Connect call failed ('201.21.88.65', 443)] The above exception was the direct cause of the following exception: Traceback (most recent call last): File "DiscordBot.py", line 128, in <module> client.run(TOKEN) File "/home/Demotry/.local/lib/python3.6/site-packages/discord/client.py", line 519, in run self.loop.run_until_complete(self.start(args, kwargs)) File "/usr/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete return future.result() File "/home/Demotry/.local/lib/python3.6/site-packages/discord/client.py", line 490, in start yield from self.login(args, kwargs) File "/home/Demotry/.local/lib/python3.6/site-packages/discord/client.py", line 416, in login yield from getattr(self, 'login' + str(n))(*args, kwargs) File "/home/Demotry/.local/lib/python3.6/site-packages/discord/client.py", line 346, in _login_1 data = yield from self.http.static_login(token, bot=is_bot) File "/home/Demotry/.local/lib/python3.6/site-packages/discord/http.py", line 258, in static_login data = yield from self.request(Route('GET', '/users/@me')) File "/home/Demotry/.local/lib/python3.6/site-packages/discord/http.py", line 137, in request r = yield from self.session.request(method, url, **kwargs) File "/home/Demotry/.local/lib/python3.6/site-packages/aiohttp/client.py", line 555, in iter resp = yield from self._coro File "/home/Demotry/.local/lib/python3.6/site-packages/aiohttp/client.py", line 198, in _request conn = yield from self._connector.connect(req) File "/home/Demotry/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 314, in connect .format(key, exc.strerror)) from exc aiohttp.errors.ClientOSError: [Errno 111] Cannot connect to host discordapp.com:443 ssl:True [Can not connect to discordapp.com:443 [Connect call failed ('201.21.88.65', 443)]] Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f009e03d3c8>

You need to make your code use the proxy. See http://help.pythonanywhere.com/pages/403ForbiddenError/

No idea how to use proxy any info how to use proxy.

Have a look at the documentation of the library that you're using to connect to discord. Though some libraries don't support proxies. If that's the case, either raise it as an issue with the maintainers of the library, or use a library that does.