added the contrib package and discord package, resolves #1071

pull/1089/head
Scott Anderson 2020-06-08 16:54:52 -06:00
parent e26a8527f9
commit 26e66598a2
3 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,16 @@
---
title: Flux user-contributed functions
list_title: User-contributed functions
description: >
User-contributed packages and functions are contributed and maintained by members of the InfluxDB and Flux communities.
menu:
v2_0_ref:
name: User-contributed
parent: Flux standard library
weight: 202
v2.0/tags: [contributed, functions, package]
---
User-contributed packages and functions are contributed and maintained by members of the InfluxDB and Flux communities.
{{< children >}}

View File

@ -0,0 +1,28 @@
---
title: Flux Discord package
list_title: Discord package
description: >
The Flux Discord package provides functions for sending data to Discord.
Import the `contrib/chobbs/discord` package.
menu:
v2_0_ref:
name: Discord
parent: User-contributed
weight: 202
v2.0/tags: [functions, discord, package]
---
The Flux Discord package provides functions for sending data to Discord.
Import the `contrib/chobbs/discord` package:
```js
import "contrib/chobbs/discord"
```
{{< children type="functions" show="pages" >}}
{{% note %}}
#### Package author and maintainer
**Github:** [@chobbs](https://github.com/chobbs)
**InfluxDB Slack:** [@craig](https://influxdata.com/slack)
{{% /note %}}

View File

@ -0,0 +1,86 @@
---
title: discord.send() function
description: >
The `discord.send()` function sends a single message to a Discord channel using
a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&amp?page=3).
menu:
v2_0_ref:
name: discord.send
parent: Discord
weight: 202
---
The `discord.send()` function sends a single message to a Discord channel using
a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&amp?page=3).
_**Function type:** Output_
```js
import "contrib/chobbs/discord"
discord.send(
webhookToken: "mySuPerSecRetTokEn",
webhookID: "123456789",
username: "username",
content: "This is an example message",
avatar_url: "https://example.com/avatar_pic.jpg"
)
```
## Parameters
### webhookToken
Discord [webhook token](https://discord.com/developers/docs/resources/webhook).
_**Data type:** String_
### webhookID
Discord [webhook ID](https://discord.com/developers/docs/resources/webhook).
_**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
```js
import "contrib/chobbs/discord"
import "influxdata/influxdb/secrets"
token = secrets.get(key: "DISCORD_TOKEN")
lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> findRecord(fn: (key) => true, idx: 0)
discord.send(
webhookToken:token,
webhookID: "1234567890",
username: "chobbs",
content: "The current status is \"${lastReported.status}\".",
avatar_url: "https://staff-photos.net/pic.jpg"
)
```
{{% note %}}
#### Package author and maintainer
**Github:** [@chobbs](https://github.com/chobbs)
**InfluxDB Slack:** [@craig](https://influxdata.com/slack)
{{% /note %}}