#TypeError 'NoneType' object is not iterable
1 messages · Page 1 of 1 (latest)
Bruh my eyeeessss!!!
what are those colors 🤢
?tag codeblock
Please put your code in a code block:
```py
Here is your Code
```
That makes reading code in Discord a lot easier:
print("This is an example.")
@bot.slash_command(name='warns', description='Просмотр варнов')
async def warn1(ctx, user: Option(discord.Member)):
use = user.id
warns = discord.Embed(title=f'Предупрежления {ctx.author}')
for warn in b.get_warn(b, user):
warns.add_field(name=f'№ {warn[0]}', value=f'Причина: `{warn[2]}` Модератор: <@{warn[1]}>')
TypeError 'NoneType' object is not iterable
in get_warn you are not returning anything, so when you are iterating over it in the for loop, it's iterating over nothing.
Try this:
def get_warn(self, user):
warn_list = self.cr.execute("SELECT id, modid, reason FROM warns WHERE userid=?",(user,))
return warn_list
i want to make warns list but when i get warns from database i've got error:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/commands/core.py", line 881, in _invoke
await self.callback(ctx, **kwargs)
File "/Volumes/Danya disk/coding/Py-cord/HFD/main.py", line 297, in warn1
for warn in b.get_warn(b, user):
File "/Volumes/Danya disk/coding/Py-cord/HFD/core/bd.py", line 65, in get_warn
self.cr.execute("SELECT id, modid, reason FROM warns WHERE userid = ?",(user,))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.```
**code:**
```python
@bot.slash_command(name='warns', description='Просмотр варнов')
async def warn1(ctx, user: Option(discord.Member)):
use = user.id
warns = discord.Embed(title=f'Предупрежления {ctx.author}')
for warn in b.get_warn(b, user):
warns.add_field(name=f'№ {warn[0]}', value=f'Причина: `{warn[2]}` Модератор: <@{warn[1]}>')
def get_warn(self, user):
self.cr.execute("SELECT id, modid, reason FROM warns WHERE userid = ?",(user,))```
try using this-
for warn in b.get_warn(use):
you were passing user object itself rather than the user's id
also, try learning a bit more about oop
you were passing in b as a parameter. but that will be done automatically as you doing b.get_warn
thanks
but now i've got this error TypeError: 'NoneType' object is not iterable
hmm dk. wait for someone else
I can however its a bit hard to explain
So you do know
Sqlite returns a tuple value
Plus I am playing apex so typing is hard
Yes
You can explain later
4 min, ok?