This module assists with using Discord Webhooks. You use classes to build objects, which makes sending embeds a breeze!
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
PSDsHook
docs
examples
media
tests
.gitignore
CHANGELOG.md
LICENSE
README.md
appveyor.yml
azure-pipelines.yml
build.ps1
deploy.psdeploy.ps1
mkdocs.yml
psake.ps1

README.md

Build status Build Status Documentation Status License: MIT

hook

PowerShell -> Discord Webhook

PSDsHook allows you to easily utilize Discord webhooks via PowerShell.

This module will work with PowerShell version 5.1, with the exception of sending binary files.

If you need to send files to Discord channels, you'll want to use PowerShell Core until support is added for 5.1.

Getting Started

Install module from the PowerShell Gallery

This is the easiest way to use the module! To install it, use:

Install-Module PSDsHook

Then check out the documentation and examples to get started!

Build instructions coming soon if you would like to build it yourself. Simply running build.ps1 should take care of the basic tasks. You can use the module from the /out directory if it compiles.

Quick and Dirty

To create the configuration file, run:

Invoke-PsDsHook -CreateConfig -WebhookUrl 'https://discordapp.com/api/webhooks/4221456689714954341337/thisisfakeandwillnotwork' -Verbose

To create/send an embed, run:

using module PSDsHook

If the module is not installed into a folder within one of these directories:

($env:PSModulePath -split "$([IO.Path]::PathSeparator)")

You'll need to use the following statement and point it to your local copy of the module's built .psm1 file.

using module 'C:\users\thegn\repos\PsDsHook\out\PSDsHook\0.0.1\PSDsHook.psm1'

(optional) Specify a thumbnail url to use in the hook

$thumbUrl = 'https://static1.squarespace.com/static/5644323de4b07810c0b6db7b/t/5aa44874e4966bde3633b69c/1520715914043/webhook_resized.png'

Create embed builder object via the [DiscordEmbed] class. You can customize the title and description.

$embedBuilder = [DiscordEmbed]::New(
                    'title',
                    'description'
                )

Add our thumbnail to the embed:

$embedBuilder.AddThumbnail(
    [DiscordThumbnail]::New(
        $thumbUrl
    )
)

Add a color:

$embedBuilder.WithColor(
    [DiscordColor]::New(
            'purple'
    )
)

Add an author:

$embedBuilder.AddAuthor(
    [DiscordAuthor]::New(
        'Author',
        $thumbUrl
    )
)

Add a footer:

$embedBuilder.AddFooter(
    [DiscordFooter]::New(
        'footer',
        $thumbUrl
    )
)

Add an image:

$embedBuilder.AddImage(
    [DiscordImage]::New(
        $thumbUrl
    )
)

Finally, call the function that will send the embed array to the webhook url:

Invoke-PSDsHook -EmbedObject $embedBuilder -Verbose

example