diff --git a/discord/cdn_endpoints.go b/discord/cdn_endpoints.go index 4e4a3eb9..f3dc0e56 100644 --- a/discord/cdn_endpoints.go +++ b/discord/cdn_endpoints.go @@ -104,9 +104,9 @@ func (e CDNEndpoint) URL(format FileFormat, values QueryValues, params ...any) s return urlPrint(CDN+e.Route+"."+format.String(), params...) + query } -func DefaultCDNConfig() *CDNConfig { +func DefaultCDNConfig(format FileFormat) *CDNConfig { return &CDNConfig{ - Format: FileFormatPNG, + Format: format, Values: QueryValues{}, } } @@ -138,7 +138,13 @@ func WithFormat(format FileFormat) CDNOpt { } func formatAssetURL(cdnRoute *CDNEndpoint, opts []CDNOpt, params ...any) string { - config := DefaultCDNConfig() + format := FileFormatNone + if len(cdnRoute.Formats) > 0 { // just in case someone fucks up + // use the first provided format in the route definition itself. if the user provides a different format, this will be overriden by the Apply function call below + // previously, the default format was png, which would cause issues for cdn endpoints like attachments and soundboard sounds, requiring custom "overrides" + format = cdnRoute.Formats[0] + } + config := DefaultCDNConfig(format) config.Apply(opts) var lastStringParam string