slack-attachment-generator

1.0.0 • Public • Published

Slack attachment generator

Simply attachment generator for slack.

Getting started

$ npm i -S slack-attachment-generator

Usage

As function

const {
  generateAttachments
} = require('slack-attachment-generator')
const attachments = generateAttachments(
  'Title',
  'danger',
  [
    {
      title: '===',
      value: ' '
    }
  ]
)

It will be returns following object.

[{
  color: 'danger',
  text: 'Title',
  fallback: '',
  footer: '',
  fields: [
    {
      title: '===',
      value: ' '
    }
  ]
}]

As Class (single method)

const Attachments = new SlackAttachments()
Attachments.addAttachment(
  'Title',
  'danger',
  [
    {
      title: '===',
      value: ' '
    }
  ]
)
const attachments = Attachments.getAttachment()

[{
  color: 'danger',
  text: 'Title',
  fallback: '',
  footer: '',
  fields: [
    {
      title: '===',
      value: ' '
    }
  ]
}]

As Class (as class)

const Attachments = new SlackAttachments()
Attachments.setMessage('Hello')
Attachments.setFallBackMessage('fallback')
Attachments.setColor('good')
Attachments.setFooter('footer')
Attachments.addAttachmentFields('Title', 'value')
Attachments.addAttachmentFields('Title2', 'content', true)
Attachments.pushAttachment()
Attachments.getAttachment()

[{
  color: 'good',
  text: 'Hello',
  fallback: 'fallback',
  footer: 'footer',
  fields: [
    {
      title: 'Title',
      value: 'value'
    }, {
      short: 'true',
      title: 'Title2',
      value: 'content'
    }
  ]
}]

Readme

Keywords

none

Package Sidebar

Install

npm i slack-attachment-generator

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

5.68 kB

Total Files

7

Last publish

Collaborators

  • hideokamoto