Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SetFooterIconf, SetImagef, SetThumbnailf and SetURLf #204

Merged
merged 2 commits into from Oct 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions discord/embed_builder.go
Expand Up @@ -122,6 +122,15 @@ 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 {
if b.Footer == nil {
b.Footer = &EmbedFooter{}
}
b.Footer.IconURL = fmt.Sprintf(iconURL, a...)
return b
}

// SetImage sets the image of the EmbedBuilder
func (b *EmbedBuilder) SetImage(url string) *EmbedBuilder {
if b.Image == nil {
Expand All @@ -131,6 +140,15 @@ 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 {
if b.Image == nil {
b.Image = &EmbedResource{}
}
b.Image.URL = fmt.Sprintf(url, a...)
return b
}

// SetThumbnail sets the thumbnail of the EmbedBuilder
func (b *EmbedBuilder) SetThumbnail(url string) *EmbedBuilder {
if b.Thumbnail == nil {
Expand All @@ -140,12 +158,27 @@ 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 {
if b.Thumbnail == nil {
b.Thumbnail = &EmbedResource{}
}
b.Thumbnail.URL = fmt.Sprintf(url, a...)
return b
}

// 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 {
b.URL = fmt.Sprintf(url, a...)
return b
}

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