Skip to content

Commit

Permalink
add SetFooterIconf, SetImagef, SetThumbnailf and SetURLf (#204)
Browse files Browse the repository at this point in the history
* add SetFooterIconf, SetImagef, SetThumbnailf and SetURLf

* Update embed_builder.go
  • Loading branch information
itasli committed Oct 14, 2022
1 parent 5cad8df commit 17ccdf3
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions discord/embed_builder.go
Expand Up @@ -34,8 +34,7 @@ func (b *EmbedBuilder) SetDescription(description string) *EmbedBuilder {

// SetDescriptionf sets the description of the EmbedBuilder with format
func (b *EmbedBuilder) SetDescriptionf(description string, a ...any) *EmbedBuilder {
b.Description = fmt.Sprintf(description, a...)
return b
return b.SetDescription(fmt.Sprintf(description, a...))
}

// SetEmbedAuthor sets the author of the EmbedBuilder using an EmbedAuthor struct
Expand Down Expand Up @@ -64,6 +63,11 @@ func (b *EmbedBuilder) SetAuthorName(name string) *EmbedBuilder {
return b
}

// SetAuthorNamef sets the author name of the EmbedBuilder with format
func (b *EmbedBuilder) SetAuthorNamef(name string, a ...any) *EmbedBuilder {
return b.SetAuthorName(fmt.Sprintf(name, a...))
}

// SetAuthorURL sets the author URL of the EmbedBuilder
func (b *EmbedBuilder) SetAuthorURL(url string) *EmbedBuilder {
if b.Author == nil {
Expand All @@ -73,6 +77,11 @@ func (b *EmbedBuilder) SetAuthorURL(url string) *EmbedBuilder {
return b
}

// SetAuthorURLf sets the author URL of the EmbedBuilder with format
func (b *EmbedBuilder) SetAuthorURLf(url string, a ...any) *EmbedBuilder {
return b.SetAuthorURL(fmt.Sprintf(url, a...))
}

// SetAuthorIcon sets the author icon of the EmbedBuilder
func (b *EmbedBuilder) SetAuthorIcon(iconURL string) *EmbedBuilder {
if b.Author == nil {
Expand All @@ -82,6 +91,11 @@ func (b *EmbedBuilder) SetAuthorIcon(iconURL string) *EmbedBuilder {
return b
}

// SetAuthorIconf sets the author icon of the EmbedBuilder with format
func (b *EmbedBuilder) SetAuthorIconf(iconURL string, a ...any) *EmbedBuilder {
return b.SetAuthorIcon(fmt.Sprintf(iconURL, a...))
}

// SetColor sets the color of the EmbedBuilder
func (b *EmbedBuilder) SetColor(color int) *EmbedBuilder {
b.Color = color
Expand Down Expand Up @@ -113,6 +127,11 @@ func (b *EmbedBuilder) SetFooterText(text string) *EmbedBuilder {
return b
}

// SetFooterText sets the footer text of the EmbedBuilder with format
func (b *EmbedBuilder) SetFooterTextf(text string, a ...any) *EmbedBuilder {
return b.SetFooterText(fmt.Sprintf(text, a...))
}

// SetFooterIcon sets the footer icon of the EmbedBuilder
func (b *EmbedBuilder) SetFooterIcon(iconURL string) *EmbedBuilder {
if b.Footer == nil {
Expand All @@ -122,6 +141,11 @@ func (b *EmbedBuilder) SetFooterIcon(iconURL string) *EmbedBuilder {
return b
}

// SetFooterIconf sets the footer icon of the EmbedBuilder
func (b *EmbedBuilder) SetFooterIconf(iconURL string, a ...any) *EmbedBuilder {
return b.SetFooterIcon(fmt.Sprintf(iconURL, a...))
}

// SetImage sets the image of the EmbedBuilder
func (b *EmbedBuilder) SetImage(url string) *EmbedBuilder {
if b.Image == nil {
Expand All @@ -131,6 +155,11 @@ func (b *EmbedBuilder) SetImage(url string) *EmbedBuilder {
return b
}

// SetImagef sets the image of the EmbedBuilder with format
func (b *EmbedBuilder) SetImagef(url string, a ...any) *EmbedBuilder {
return b.SetImage(fmt.Sprintf(url, a...))
}

// SetThumbnail sets the thumbnail of the EmbedBuilder
func (b *EmbedBuilder) SetThumbnail(url string) *EmbedBuilder {
if b.Thumbnail == nil {
Expand All @@ -140,12 +169,22 @@ func (b *EmbedBuilder) SetThumbnail(url string) *EmbedBuilder {
return b
}

// SetThumbnailf sets the thumbnail of the EmbedBuilder with format
func (b *EmbedBuilder) SetThumbnailf(url string, a ...any) *EmbedBuilder {
return b.SetThumbnail(fmt.Sprintf(url, a...))
}

// SetURL sets the URL of the EmbedBuilder
func (b *EmbedBuilder) SetURL(url string) *EmbedBuilder {
b.URL = url
return b
}

// SetURLf sets the URL of the EmbedBuilder with format
func (b *EmbedBuilder) SetURLf(url string, a ...any) *EmbedBuilder {
return b.SetURL(fmt.Sprintf(url, a...))
}

// SetTimestamp sets the timestamp of the EmbedBuilder
func (b *EmbedBuilder) SetTimestamp(time time.Time) *EmbedBuilder {
b.Timestamp = &time
Expand Down

0 comments on commit 17ccdf3

Please sign in to comment.