Ask coding questions

← Back to all posts
TypeError: 'NoneType' object is not subscriptable | Discord.py
DwellerIgor

file currency.py line 58. I'm making a currency system and bot is supposed to add credits when someone sends a message, but he doesn't do that and I get the error.
Error: Ignoring exception in on_ready Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "main.py", line 37, in on_ready member_id = int(data[0]) ValueError: invalid literal for int() with base 10: 'Kar' Ignoring exception in on_message Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "/home/runner/THANOS-COMMANDS/currency.py", line 145, in on_message await self.add_credits(message.author) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 372, in __call__ return await self.callback(self.cog, *args, **kwargs) File "/home/runner/THANOS-COMMANDS/currency.py", line 57, in add_credits result1 = cursor.fetchone()[0] TypeError: 'NoneType' object is not subscriptable

How to fix that? Thank you!

Voters
DwellerIgor
Comments
hotnewtop
Coder100

The error means that your data object is None, but that doesn't really make much sense on its own.
Your loop on line 35 will give you more insight, perhaps line is None? I recommend you print the lines variable to find out exactly what is being read.

DwellerIgor

did you see currency.py file? what you are talking about is another function @Coder100