Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/services/discord.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ The shoutrrr service URL should look like this:

--8<-- "docs/services/discord/config.md"

## Optional: Sending messages to a specific thread

Discord supports sending messages via webhook to threads. You can target a specific thread by appending
`?thread_id=<id>` to the end of the url.

!!! info ""
### Example

```
discord://<token>@<webhook_id>?thread_id=1234567890123456789
```

To get the thread ID:
- Open a Discord Thread
- Right click -> copy link
- OR Right click -> copy thread ID (Developer mode turned on in discord settings)

!!! warning ""
A valid thread_id must is 19 digits long. If extracting from a link don't confuse the channel ID and thread ID.

## Creating a webhook in Discord

1. Open your channel settings by first clicking on the gear icon next to the name of the channel.
Expand Down
12 changes: 10 additions & 2 deletions pkg/services/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,19 @@ func (service *Service) Initialize(configURL *url.URL, logger types.StdLogger) e

// CreateAPIURLFromConfig takes a discord config object and creates a post url
func CreateAPIURLFromConfig(config *Config) string {
// Optional queryParams
queryParams := ""
if config.ThreadID != "" {
queryParams = "?thread_id=" + config.ThreadID
}

return fmt.Sprintf(
"%s/%s/%s",
"%s/%s/%s%s",
hookURL,
config.WebhookID,
config.Token)
config.Token,
queryParams,
)
}

func doSend(payload []byte, postURL string) error {
Expand Down
1 change: 1 addition & 0 deletions pkg/services/discord/discord_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
ColorDebug uint `key:"colorDebug" default:"0x7b00ab" desc:"The color of the left border for debug messages" base:"16"`
SplitLines bool `key:"splitLines" default:"Yes" desc:"Whether to send each line as a separate embedded item"`
JSON bool `key:"json" default:"No" desc:"Whether to send the whole message as the JSON payload instead of using it as the 'content' field"`
ThreadID string `key:"thread_id" default:"" desc:"Optional thread ID for posting into a channel thread"`
}

// LevelColors returns an array of colors with a MessageLevel index
Expand Down