Traceback (most recent call last):
File "C:\Users\Elyes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ui\modal.py", line 229, in _scheduled_task
await self.callback(interaction)
File "d:\Workspaces\Python Workspaces\Discord Bots\JustMe Bot\bot.py", line 143, in callback
print(user.name)
AttributeError: 'NoneType' object has no attribute 'name
I don't know why this error shows, because it doesn't make any sense. I've tried to change the disnake.utils.get
function, but it doesn't work.
# The callback received when the user input is completed.
async def callback(self, inter: disnake.ModalInteraction):
# Get the input from the modal
for key, value in inter.text_values.items():
# get user by name
if key == "name":
# split value by #
username, discriminator = value.split("#")
user = disnake.utils.get(inter.channel.guild.members, name=username, discriminator=discriminator)
print(user.name)
Refer to documentation https://docs.disnake.dev/en/latest/api.html?highlight=utils#disnake.utils.get
It clearly states: If nothing matching the passed attributes is found, None is returned.
When there are no results of getting a value in an iterable sequence disnake.utils.get
put the value None in the user
variable
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.