belguawhale / Discord-Werewolf

A discord bot that runs a game of Werewolf.
MIT License
81 stars 52 forks source link

I'm having a problem installing #7

Closed ViMichy closed 7 years ago

ViMichy commented 7 years ago

when I type the "python bot.py" this message appear File "bot.py", line 69 async def on_ready(): ^ SyntaxError: invalid syntax

I'm on mac if it has something to do with it

belguawhale commented 7 years ago

What version of python are you using? Discord Werewolf requires at least Python 3.5

ViMichy commented 7 years ago

python 3.6.1

belguawhale commented 7 years ago

Try python3 -V. If that gives you Python 3.6.1, use python3 bot.py instead of python bot.py

ViMichy commented 7 years ago

It gives me this: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send self.connect() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect server_hostname=server_hostname) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket _context=self, _session=session) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 808, in init self.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1061, in do_handshake self._sslobj.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "bot.py", line 50, in lang = get_jsonparsed_data(url) File "bot.py", line 43, in get_jsonparsed_data response = urllib.request.urlopen(url) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open response = self._open(req, data) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open '_open', req) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(*args) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open context=self._context, check_hostname=self._check_hostname) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)> Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x103b77978>

belguawhale commented 7 years ago

Looks like a SSL error O.o Try commenting out the following block of code in the file (lines 49 to 53 inclusive)


url = "https://raw.githubusercontent.com/belguawhale/Discord-Werewolf/master/lang/" + MESSAGE_LANGUAGE + ".json"
lang = get_jsonparsed_data(url)
if not lang:
    print("Could not find language {}, fallback on en".format(MESSAGE_LANGUAGE))
    lang = get_jsonparsed_data("https://raw.githubusercontent.com/belguawhale/Discord-Werewolf/master/lang/en.json")```
ViMichy commented 7 years ago

now it gives this: BACKING UP SETTINGS Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 601, in _create_direct_connection local_addr=self._local_addr) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 802, in create_connection sock, protocol_factory, ssl, server_hostname) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 828, in _create_connection_transport yield from waiter File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/sslproto.py", line 503, in data_received ssldata, appdata = self._sslpipe.feed_ssldata(data) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/sslproto.py", line 201, in feed_ssldata self._sslobj.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 304, in connect yield from self._create_connection(req) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 578, in _create_connection transport, proto = yield from self._create_direct_connection(req) File "/Library/Frameworks/Python.framework/Versions/3.6/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 1] Can not connect to discordapp.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "bot.py", line 2885, in client.run(TOKEN) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 519, in run self.loop.run_until_complete(self.start(*args, kwargs)) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete return future.result() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 490, in start yield from self.login(*args, *kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 416, in login yield from getattr(self, 'login' + str(n))(args, kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/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 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 195, in static_login data = yield from self.get(self.ME) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 105, in request r = yield from self.session.request(method, url, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/client.py", line 555, in iter resp = yield from self._coro File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/client.py", line 198, in _request conn = yield from self._connector.connect(req) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 314, in connect .format(key, exc.strerror)) from exc aiohttp.errors.ClientOSError: [Errno 1] Cannot connect to host discordapp.com:443 ssl:True [Can not connect to discordapp.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)]] Task was destroyed but it is pending! task: <Task pending coro=<backup_settings_loop() running at bot.py:2661> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x103b78eb8>()]>> Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x103b7e940> Task was destroyed but it is pending! task: <Task pending coro=<do_rate_limit_loop() running at bot.py:2625> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x103b780d8>()]>>

belguawhale commented 7 years ago

Try updating the dependencies using the following commands:

python3 -m pip install -U aiohttp
python3 -m pip install -U asyncio
python3 -m pip install -U discord.py
ViMichy commented 7 years ago

still gives me the same error

belguawhale commented 7 years ago

There appears to be an error with SSL cerificates on Mac on Python 3.6. Try double-clocking the file located at /Applications/Python 3.6/Install Certificates.command

ViMichy commented 7 years ago

now it gives this: BACKING UP SETTINGS Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 256, in static_login data = yield from self.request(Route('GET', '/users/@me')) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 198, in request raise HTTPException(r, data) discord.errors.HTTPException: UNAUTHORIZED (status code: 401): 401: Unauthorized

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "bot.py", line 2885, in client.run(TOKEN) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 519, in run self.loop.run_until_complete(self.start(*args, kwargs)) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete return future.result() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 490, in start yield from self.login(*args, *kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 416, in login yield from getattr(self, 'login' + str(n))(args, kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/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 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 260, in static_login raise LoginFailure('Improper token has been passed.') from e discord.errors.LoginFailure: Improper token has been passed. Task was destroyed but it is pending! task: <Task pending coro=<backup_settings_loop() running at bot.py:2661> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x103b61e88>()]>> Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x103b675c0> Task was destroyed but it is pending! task: <Task pending coro=<do_rate_limit_loop() running at bot.py:2625> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x103b610a8>()]>>

belguawhale commented 7 years ago

Are you sure you are using the correct token? You can get it by going to https://discordapp.com/developers/applications/me, clicking on the bot application, and clicking Reveal Token

ViMichy commented 7 years ago

am i supposed to put the token with the ' or without it. either way it gives an error

belguawhale commented 7 years ago

Put the token under config.py so the line reads something like TOKEN = 'insert token here'

ViMichy commented 7 years ago

this error now BACKING UP SETTINGS Logged in as Were bot 295973382296567809

Ignoring exception in on_ready Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event yield from getattr(self, event)(*args, **kwargs) File "bot.py", line 74, in on_ready await log(1, 'on_ready triggered!') File "bot.py", line 1697, in log await client.send_message(client.get_channel(DEBUG_CHANNEL), logmsg) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 1145, in send_message channel_id, guild_id = yield from self._resolve_destination(destination) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 289, in _resolve_destination raise InvalidArgument(fmt.format(destination)) discord.errors.InvalidArgument: Destination must be Channel, PrivateChannel, User, or Object. Received NoneType

belguawhale commented 7 years ago

Did you put the debug channel's ID into config.py as a string?

ViMichy commented 7 years ago

?? the only thing i changed in the config.py was putting the token

belguawhale commented 7 years ago

Put the server's id, lobby channel's id, and the debug channel's id into config.py in their respective locations

ViMichy commented 7 years ago

it opens in discord. do i have to put something on the PLAYERS_ROLE_NAME = 'Players' ADMINS_ROLE_NAME = 'Admins' also there is a: [WARNING] Could not find Werewolf Notify role Werewolf Notify

belguawhale commented 7 years ago
GAME_CHANNEL = '255518237356195840'
DEBUG_CHANNEL = '255531567936569344'
WEREWOLF_SERVER = '255517530783875073'

It should look something like this

ViMichy commented 7 years ago

that part works but it gives me on discord: [INFO] on_ready triggered! [ERROR] @ViMichy Could not find players role Players [ERROR] @ViMichy Could not find admins role Admins [WARNING] Could not find Werewolf Notify role Werewolf Notify

belguawhale commented 7 years ago

Did you create a Players role and an Admins role?

ViMichy commented 7 years ago

i just did. now it gives me this: [INFO] on_ready triggered! [DEBUG] Players role id: 298198243958063126 [DEBUG] Admins role id: 295958905794854914 [WARNING] Could not find Werewolf Notify role Werewolf Notify

belguawhale commented 7 years ago

The last one is fine; you can safely ignore it. If you wish, you can create a werewolf notify role though

ViMichy commented 7 years ago

what does that do and how do i do it?

belguawhale commented 7 years ago

The Werewolf Notify role is an outdated way to notify people to join the game; !notify works much better

belguawhale commented 7 years ago

Anyways I'm closing the issue now since it has been resolved. Please pm me on discord if you have any more questions (you can join the official werewolf server using the link in the repository description)

Kedoichi commented 4 years ago

Looks like a SSL error O.o

In which file sir