Using Discord Webhooks and Embeds With PowerShell (Part 2)

Welcome to part 2 of my series of using PowerShell to send Discord webhooks. In this post I will be going over how to send embeds. If you’re just getting started with the process, I recommend reading Part 1 first.

I’ve created a module that makes it easy to work with embeds, store configurations that contain your webhook urls, and make the whole experience seamless by using PowerShell classes. It will get its own post, and if you’re interested check out the Github repo here.

Title and description are strings so those are easy. Color is also a string, but a string that represents a decimal value for the color. For now it is important to understand the value for green is 4289797.

$color='4289797'$title='Greetings from PowerShell!'$description='This is an embed. It looks much nicer than just sending text over!'

3. Now it’s time to create a PSCustomObject that contains those items to add to the array we created earlier.

$title='Greetings with a picture!'$description='This embed should now contain an image'$color='9442302'$embedObject=[PSCustomObject]@{title=$titledescription=$descriptioncolor=$colorthumbnail=$thumbnailObject}

3. Now we’ll create an array, add the embed object, create the payload, and send that over to the webhook url.

Github Repo With Example Code

Summary

Embeds are a little more complicated, but not too hard to work in with these webhooks and PowerShell. There is even more you can do, including adding fields to embeds and sending files. In part 3 I will be go over just how to do that!

Let me know if you have any ideas, questions, or feedback in the comments below!

gngrninja.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com