我正试图从消息中获取用户的图像,并将其显示在嵌入文件中,但由于某些原因,它无法工作
我对author/footer图标使用了相同的代码,它工作起来没有问题,我不明白为什么它不工作
if len(message.attachments) > 0:
attachment = message.attachments[0]
if attachment.filename.endswith(".jpg") or attachment.filename.endswith(".jpeg") or attachment.filename.endswith(".png") or attachment.filename.endswith(".webp") or attachment.filename.endswith(".gif"):
self.image = attachment.url
elif "https://images-ext-1.discordapp.net" in message.content or "https://tenor.com/view/" in message.content:
self.image = message.content
# In a separate function
e = discord.Embed()
e.set_image(url=self.image)
我试着打印self.image
,我得到了url,所以我不知道为什么它不起作用(顺便说一句,缩略图也发生了同样的事情)
“分离函数”必须与检查邮件附件的位置在同一类中。我已经把这个“其他功能”作为一个命令来发送嵌入到通道,它工作得很好。这个班是一个不和谐的齿轮
当然,您还需要具有设置功能
因为“test”类是一个Cog,所以需要从主文件加载它
相关问题 更多 >
编程相关推荐