Skip to content

Commit

Permalink
Add simple sample send_discord_message
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyanka-Chatterjee-2000 committed Nov 29, 2023
1 parent eb722c2 commit 2102b7f
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
8 changes: 8 additions & 0 deletions simple/send_discord_message/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Send Discord Message

Send a message to a Discord channel.

## Usage

- Add your Discord API token to `flowpipe.pvars`
- Run the pipeline and specify the `channel_id` and `message` args, e.g., `flowpipe pipeline run send_discord_message --arg 'channel_id=1234567890' --arg 'message=Hello world!'
1 change: 1 addition & 0 deletions simple/send_discord_message/flowpipe.fpvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
discord_token = "YourBotToken"
13 changes: 13 additions & 0 deletions simple/send_discord_message/mod.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mod "send_discord_message" {
title = "Send Discord Message"
description = "Send a message to a Discord channel."

require {
mod "github.com/turbot/flowpipe-mod-discord" {
version = "0.0.1-rc.0"
args = {
token = var.discord_token
}
}
}
}
33 changes: 33 additions & 0 deletions simple/send_discord_message/send_discord_message.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pipeline "send_discord_message" {
title = "Send Discord Message"
description = "Send a message to a Discord channel"

param "discord_token" {
description = "The Discord BOT token to use"
type = string
default = var.discord_token
}

param "discord_channel_id" {
description = "The ID of the channel to send the message to"
type = number
}

param "discord_message" {
description = "The message to send."
type = string
}

step "pipeline" "create_message" {
pipeline = discord.pipeline.create_message
args = {
token = param.discord_token
channel_id = param.discord_channel_id
message = param.discord_message
}
}

output "create_message_check" {
value = !is_error(step.pipeline.create_message) ? "Message '${param.discord_message}' sent to ${param.discord_channel_id}" : "Error sending message: ${error_message(step.pipeline.create_message)}"
}
}
4 changes: 4 additions & 0 deletions simple/send_discord_message/variables.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "discord_token" {
type = string
description = "The Discord bot token."
}

0 comments on commit 2102b7f

Please sign in to comment.