diff --git a/discord/cdn_endpoints.go b/discord/cdn_endpoints.go index 597d3293..e9a064ca 100644 --- a/discord/cdn_endpoints.go +++ b/discord/cdn_endpoints.go @@ -102,9 +102,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{}, } } @@ -136,7 +136,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