#๐ cannot unpack non-iterable NoneType object
49 messages ยท Page 1 of 1 (latest)
@sacred elk
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Uh i cant send code
!e
x = None
a, b = x
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 2, in <module>
003 | a, b = x
004 | ^^^^
005 | TypeError: cannot unpack non-iterable NoneType object
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Show the entire traceback
2024-12-17 17:22:31 INFO discord.gateway Shard ID None has successfully RESUMED session 594c6b6cace8e0da0890957aa61ce3a6.
Re-establishing the connection...
Re-establishing the connection...
Re-establishing the connection...
Re-establishing the connection...
Re-establishing the connection...
Re-establishing the connection...
cannot unpack non-iterable NoneType object
(this happens after every message sent in server)
Seems like a partially suppressed error
Must've used
try:
...
except Exception as e:
print (e)
It's as good as suppressing the error entirely
I highly recommend you to not do this
ohh
We're missing crucial details which have been suppressed just to the error type
Which command does the error come from?
lemme detect which file it could be
you can still tell where the error is from tho
view,response=get_response(user_message)
``` causes an error
`get_response` is defined in the `Responses` file
can you send the source code of that?
there is nothing there i assume it just calls 1 function for now iwill send that
def Start():
view = customstartbutton()
# Terms and conditions
embed = discord.Embed(
title="Terms and Condition",
description="Welcome to currency Bot.",
color=discord.Color.green()
)
embed.add_field(name="1", value="1. By participating in this game, you agree to follow all community guidelines and respect fellow players.", inline=False)
embed.add_field(name="2", value="2. Any form of cheating, harassment, or abuse will result in immediate removal from the game and server.", inline=False)
embed.add_field(name='3', value="3. The game administrators reserve the right to modify these terms at any time; continued participation implies acceptance of the updated terms.", inline=False)
return view, embed
where's the get_response function defined then
from Enable import Start
import discord
def get_response(user_input: str) -> discord.embeds:
lowered: str = user_input.lower()
if 'start' in lowered:
return Start()
```
what if 'start' is not in lowered? it'd return None
no worries
your return type hint is wrong btw
discord.embeds is a module not a type
assuming customstartbutton is a view and not a button, it'd be None | tuple[discord.ui.View, discord.Embed]
so i am returning a tuple?
or none
depends
thats why theres the None | ...
it means it could either return None or tuple[discord.ui.View, discord.Embed]
depending on what you pass in
as tathya said, if start isnt there in the lowered variable, it returns None
or if you're using the typing library it would be the equivalent to-
typing.Optional[discord.ui.View]
makes it a little more readable
ahh
yea come to think of it i dont want it to return anything if it has nothing to do with bot command
so is there a better way to handle the error? like simply ignoring it?
rather than reading all msg
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.