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我不知道为什么这个错误显示,因为它没有任何意义。我试图更改disnake.utils.get函数,但它不起作用。
# 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)发布于 2022-05-11 20:15:12
参考文档https://docs.disnake.dev/en/latest/api.html?highlight=utils#disnake.utils.get
它清楚地指出:If nothing matching the passed attributes is found, None is returned.
当没有在可迭代序列中获得值的结果时,disnake.utils.get将值None放在user变量中
https://stackoverflow.com/questions/72206513
复制相似问题