Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

python 3.x - Discord.py rewrite not return cached image

i write simple cod:

@commands.Cog.listener()
async def on_raw_message_delete(self, ctx):
    if ctx.cached_message.author.bot is False:

        embed=discord.Embed(title='Deleted message:', description=ctx.cached_message.content, color=0xff00f6)
        embed.set_author(name = ctx.cached_message.author, icon_url=ctx.cached_message.author.avatar_url)

        embed.set_image(url = ctx.cached_message.attachments[0].url)
        await ctx.cached_message.channel.send(embed = embed)

and this code didn't set image because it was access denied response. Image url response(if I go to url):

<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.</Details>
</Error>

how can I send cached image?

p.s. I know there is a error in this code if attachments is None.

question from:https://stackoverflow.com/questions/65918628/discord-py-rewrite-not-return-cached-image

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

i replace ctx.cached_message.attachments[0].url to ctx.cached_message.attachments[0].proxy_url and it work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...