From 17ccdf302f770a6d3ab7f2987b8ee4fd57428051 Mon Sep 17 00:00:00 2001 From: itasli Date: Fri, 14 Oct 2022 21:59:36 +0200 Subject: [PATCH] add SetFooterIconf, SetImagef, SetThumbnailf and SetURLf (#204) * add SetFooterIconf, SetImagef, SetThumbnailf and SetURLf * Update embed_builder.go --- discord/embed_builder.go | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/discord/embed_builder.go b/discord/embed_builder.go index 515179ad..53f2b16a 100644 --- a/discord/embed_builder.go +++ b/discord/embed_builder.go @@ -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 @@ -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 { @@ -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 { @@ -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 @@ -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 { @@ -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 { @@ -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 { @@ -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