NekoTony / Neko-Cogs

The only TwentySix-Red cogs made out of boredeom, loneliness, and what i think is sweat.
5 stars 12 forks source link

Q20 TypeError: list indices must be integers or slices, not str #22

Open Xardevon opened 6 years ago

Xardevon commented 6 years ago

When using the Q20 cog, I'm getting the following error after a user gets to do their final guess, and the answer ends up being incorrect:

[30/03/2018 00:23] ERROR red on_command_error 369: Exception in command 'twentyq play' Traceback (most recent call last): File "lib/discord/ext/commands/core.py", line 50, in wrapped ret = yield from coro(*args, **kwargs) File "/home/test/TestEnv/Red-DiscordBot/cogs/Q20.py", line 238, in play del userz[channel.id] TypeError: list indices must be integers or slices, not str

I'm running Python 3.6.4 on Debian 8. I'm using the default RedDiscordBot installation + Neko Cogs, so nothing has been edited.

NekoTony commented 6 years ago

Now!?

Xardevon commented 6 years ago

Unfortunately it only seems to have broken even more stuff. I couldn't load Q20 at first, which seems to have been caused by a Syntax error. On line 143 it says "self.userz self userz[channel.id]" I've managed to fix that by removing the first "self userz" there. Copying Q20... Copying Q20's data folder... [30/03/2018 22:36] ERROR owner load 69: ('invalid syntax', ('/home/test/Red-DiscordBot/cogs/Q20.py', 143, 31, ' self.userz self.userz[channel.id]\n')) Traceback (most recent call last): File "/home/test/Red-DiscordBot/cogs/owner.py", line 946, in _load_cog mod_obj = importlib.import_module(cogname) File "/home/test/.pyenv/versions/3.6.4/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 674, in exec_module File "<frozen importlib._bootstrap_external>", line 781, in get_code File "<frozen importlib._bootstrap_external>", line 741, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/test/Red-DiscordBot/cogs/Q20.py", line 143 self.userz self.userz[channel.id] ^ SyntaxError: invalid syntax

So far so good after that when loading up Q20. However, when trying to guess the answer this time (Not even the final guess) the following error happens: [30/03/2018 23:08] ERROR red on_command_error 369: Exception in command 'twentyq play' Traceback (most recent call last): File "lib/discord/ext/commands/core.py", line 50, in wrapped ret = yield from coro(*args, **kwargs) File "/home/test/TestBot/Red-DiscordBot/cogs/Q20.py", line 198, in play guess = await self.bot.wait_ftabor_message(author=user, timeout=self.q20["time"]) File "lib/discord/client.py", line 296, in __getattr__ raise AttributeError(msg.format(self.__class__, name)) AttributeError: '<class '__main__.Bot'>' object has no attribute 'wait_ftabor_message'

EDIT: Straight after posting this, I noticed "wait_ftabor_message" is a typo and is meant to be "wait_for_message" 😛 (On line 198) After fixing that error, the bot seems to run fine, even the final guess issue has been fixed! However, when starting up a second session, after people type "join" it immediately causes an error again. [30/03/2018 23:18] ERROR red on_command_error 369: Exception in command 'twentyq play' Traceback (most recent call last): File "lib/discord/ext/commands/core.py", line 50, in wrapped ret = yield from coro(*args, **kwargs) File "/home/test/TestBot/Red-DiscordBot/cogs/Q20.py", line 119, in play await self.bot.wait_for_message(channel=channel, timeout=timez, check=self.check2) File "lib/discord/client.py", line 730, in wait_for_message message = yield from asyncio.wait_for(future, timeout, loop=self.loop) File "/home/test/.pyenv/versions/3.6.4/lib/python3.6/asyncio/tasks.py", line 358, in wait_for return fut.result() File "lib/discord/client.py", line 238, in handle_message result = condition(message) File "lib/discord/client.py", line 723, in predicate result = result and check(message) File "/home/test/TestBot/Red-DiscordBot/cogs/Q20.py", line 253, in check2 self.userz[channel.id] = [] TypeError: list indices must be integers or slices, not str

Appears to be somewhat the same issue as the one you fixed for the final guess.

NekoTony commented 6 years ago

God, I don't have the time to keep this repo updated and fixed. If someone can fix it, please do.