discord.send() function

The discord.send() function is a user-contributed function maintained by the package author and can be updated or removed at any time.

The discord.send() function sends a single message to a Discord channel using a Discord webhook.

*Function type: Output*

  1. import "contrib/chobbs/discord"
  2. discord.send(
  3. webhookToken: "mySuPerSecRetTokEn",
  4. webhookID: "123456789",
  5. username: "username",
  6. content: "This is an example message",
  7. avatar_url: "https://example.com/avatar_pic.jpg"
  8. )

Parameters

webhookToken

Discord webhook token.

*Data type: String*

webhookID

Discord webhook ID.

*Data type: String*

username

Override the Discord webhook’s default username.

*Data type: String*

content

Message to send to Discord (2000 character limit).

*Data type: String*

avatar_url

Override the Discord webhook’s default avatar.

*Data type: String*

Examples

Send the last reported status to Discord
  1. import "contrib/chobbs/discord"
  2. import "influxdata/influxdb/secrets"
  3. token = secrets.get(key: "DISCORD_TOKEN")
  4. lastReported =
  5. from(bucket: "example-bucket")
  6. |> range(start: -1m)
  7. |> filter(fn: (r) => r._measurement == "statuses")
  8. |> last()
  9. |> findRecord(fn: (key) => true, idx: 0)
  10. discord.send(
  11. webhookToken:token,
  12. webhookID: "1234567890",
  13. username: "chobbs",
  14. content: "The current status is \"${lastReported.status}\".",
  15. avatar_url: "https://staff-photos.net/pic.jpg"
  16. )

Package author and maintainer

Github: @chobbs
InfluxDB Slack: @craig