Skip to content

Commit

Permalink
Use route's first defined format as default
Browse files Browse the repository at this point in the history
instead of PNG
  • Loading branch information
sebm253 committed Sep 21, 2024
1 parent ef757ee commit 5b479cf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion discord/cdn_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (e CDNEndpoint) URL(format FileFormat, values QueryValues, params ...any) s

func DefaultCDNConfig() *CDNConfig {
return &CDNConfig{
Format: FileFormatPNG,
Format: FileFormatNone,
Values: QueryValues{},
}
}
Expand Down Expand Up @@ -137,6 +137,9 @@ func WithFormat(format FileFormat) CDNOpt {

func formatAssetURL(cdnRoute *CDNEndpoint, opts []CDNOpt, params ...any) string {
config := DefaultCDNConfig()
// 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"
config.Format = cdnRoute.Formats[0]
config.Apply(opts)

var lastStringParam string
Expand Down

0 comments on commit 5b479cf

Please sign in to comment.