diff --git a/discord/embed.go b/discord/embed.go index 079ec7b4..30512902 100644 --- a/discord/embed.go +++ b/discord/embed.go @@ -34,6 +34,25 @@ type Embed struct { Fields []EmbedField `json:"fields,omitempty"` } +func (e Embed) FindField(fieldFindFunc func(field EmbedField) bool) (EmbedField, bool) { + for _, field := range e.Fields { + if fieldFindFunc(field) { + return field, true + } + } + return EmbedField{}, false +} + +func (e Embed) FindAllFields(fieldFindFunc func(field EmbedField) bool) []EmbedField { + var fields []EmbedField + for _, field := range e.Fields { + if fieldFindFunc(field) { + fields = append(fields, field) + } + } + return fields +} + // The EmbedResource of an Embed.Image/Embed.Thumbnail/Embed.Video type EmbedResource struct { URL string `json:"url,omitempty"` @@ -69,3 +88,16 @@ type EmbedField struct { Value string `json:"value"` Inline *bool `json:"inline,omitempty"` } + +type EmbedFieldPollResult string + +const ( + EmbedFieldPollResultQuestionText EmbedFieldPollResult = "poll_question_text" + EmbedFieldPollResultVictorAnswerVotes EmbedFieldPollResult = "victor_answer_votes" + EmbedFieldPollResultTotalVotes EmbedFieldPollResult = "total_votes" + EmbedFieldPollResultVictorAnswerID EmbedFieldPollResult = "victor_answer_id" + EmbedFieldPollResultVictorAnswerText EmbedFieldPollResult = "victor_answer_text" + EmbedFieldPollResultVictorAnswerEmojiID EmbedFieldPollResult = "victor_answer_emoji_id" + EmbedFieldPollResultVictorAnswerEmojiName EmbedFieldPollResult = "victor_answer_emoji_name" + EmbedFieldPollResultVictorAnswerEmojiAnimated EmbedFieldPollResult = "victor_answer_emoji_animated" +)