Skip to content

Commit

Permalink
Merge branch 'master' into patch/soundboard
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 authored Sep 21, 2024
2 parents 88f0566 + daa1902 commit 1df7005
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions discord/cdn_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1df7005

Please sign in to comment.