func (c *Client) PostMessageWithAttachment(channelID, color, title, text string, fields []*AttachmentField) error {
	attachmentFields := []slack.AttachmentField{}

	for _, field := range fields {
		attachmentFields = append(attachmentFields, slack.AttachmentField{
			Title: field.Title,
			Value: field.Value,
			Short: true,
		})
	}

	params := slack.PostMessageParameters{
		Attachments: []slack.Attachment{
			slack.Attachment{
				Title:  title,
				Text:   text,
				Color:  color,
				Fields: attachmentFields,
			},
		},
	}

	_, _, err := c.api.PostMessage(channelID, "", params)
	if err != nil {
		return errors.Wrap(err, "failed to post message to Slack")
	}

	return nil
}
// PostMessageWithAttachment posts message with attachment
PostMessageWithAttachment posts message with attachment
// PostMessageWithAttachment posts message with attachment
func (c *Client) PostMessageWithAttachment(channelID, color, title, text string, fields []*AttachmentField) error {
	attachmentFields := []slack.AttachmentField{}
	for _, field := range fields {
		attachmentFields = append(attachmentFields, slack.AttachmentField{
			Title: field.Title,
			Value: field.Value,
			Short: true,
		})
	}
	params := slack.PostMessageParameters{
		Attachments: []slack.Attachment{
			slack.Attachment{
				Title:  title,
				Text:   text,
				Color:  color,
				Fields: attachmentFields,
			},
		},
	}
	_, _, err := c.api.PostMessage(channelID, "", params)
	if err != nil {
		return errors.Wrap(err, "failed to post message to Slack")
	}
	return nil
}
func ( c * Client ) PostMessageWithAttachment ( channelID , color , title , text string , fields [ ] * AttachmentField ) error { attachmentFields := [ ] slack . AttachmentField { } for _ , field := range fields { attachmentFields = append ( attachmentFields , slack . AttachmentField { Title : field . Title , Value : field . Value , Short : true , } ) } params := slack . PostMessageParameters { Attachments : [ ] slack . Attachment { slack . Attachment { Title : title , Text : text , Color : color , Fields : attachmentFields , } , } , } _ , _ , err := c . api . PostMessage ( channelID , " " , params ) if err != nil { return errors . Wrap ( err , " " ) } return nil }
PostMessageWithAttachment posts message with attachment
PostMessageWithAttachment posts message with attachment