Auto-proxy external URLs in activity assets#895
Conversation
change_presence now automatically proxies raw external image URLs in activity assets through Discord's media CDN. This means you can pass any image URL directly to large_image/small_image on ActivityAssets and it just works, as long as the activity has an application_id set. Closes dolfies#274
dolfies
left a comment
There was a problem hiding this comment.
thanks for the pr! i don't love the general concept of automatically making api requests, but this is what the client rpc server does i guess.
| or :meth:`~discord.Application.proxy_external_assets` to retrieved a proxied URL from Discord. | ||
| Otherwise, the image will not render in clients. | ||
| Arbitrary external image URLs (e.g. ``https://example.com/image.png``) can also | ||
| be passed directly to ``large_image`` or ``small_image``. When used with |
There was a problem hiding this comment.
| be passed directly to ``large_image`` or ``small_image``. When used with | |
| be passed directly to image parameters. When used with |
excludes invite_cover_image but no point to list em anyway
| ) | ||
|
|
||
| # External URLs are automatically proxied through Discord's CDN | ||
| # when passed directly to large_image/small_image. |
There was a problem hiding this comment.
| # when passed directly to large_image/small_image. |
redundant
| import discord | ||
|
|
||
| # Your Developer Portal Application ID (used for proxying external assets) | ||
| # Your Developer Portal Application ID |
There was a problem hiding this comment.
| # Your Developer Portal Application ID | |
| # Your Developer Portal Application ID (used for proxying external assets) |
this comment is still useful
| ValueError | ||
| More than one custom activity was passed. | ||
| """ | ||
| if activity is not MISSING and activities is not MISSING: |
There was a problem hiding this comment.
instead of overcomplicating this method and polluting Client, add a _to_processed_dict() method to the Activity object that does what _proxy_activity_assets() is doing and returns the dict (make sure to not forget to stub it on BaseActivity!)
|
oh i also forgot, this needs a versionchanged: directive |
|
i lowkey kinda support this.. but then at the same time, yeah.. you don't wanna be making automatic requests. |
Right now if you want to use an external image in your activity, you have to
manually call
proxy_external_application_assets, get the proxied URLs back,then pass those into
ActivityAssets. This is pretty annoying.This makes
change_presencehandle it for you — if your activity has anapplication_idand the assets contain raw URLs that aren't from a known CDN(discord, twitch, youtube, spotify), they get proxied automatically before
being sent to the gateway.
Closes #274