【发布时间】:2019-08-07 23:18:14
【问题描述】:
如果有的话,我需要从消息中获取图片 我用的是改写版
我试过了:
message.attachments[0]['url']
但出现错误
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\vlad0\AppData\Roaming\Python\Python36\site-packages\discord\client.py", line 227, in _run_event
await coro(*args, **kwargs)
File "c:\Users\vlad0\Desktop\bot\bot.py", line 121, in on_message
print(message.attachments[0]['url'])
TypeError: 'Attachment' object is not subscriptable
如果你只留下索引或附件,你会得到这个:
<discord.message.Attachment object at 0x00000228B8E3BE80>
如何获取图片地址?
【问题讨论】:
-
显然
[]不是从附件对象获取信息的正确方法。也许你应该检查它的属性。
标签: python python-3.x discord discord.py discord.py-rewrite