PrePAN

Sign in to PrePAN

Profile

User's Modules

WebService::Discord::Webhook A module for posting messages to Discord chat service

The Discord chat service allows server ops to create "webhook"s for their server. These are special secret URLs that allow an external client to post notifications into chat by making certain HTTP requests.

(For those unfamiliar with Discord, think "Slack, if it chugged a 12 pack of Mountain Dew".)

I created this Perl module as a way to help interact with Discord webhooks. The various functions of Webhooks are wrapped in Perl functions that execute with HTTP::Tiny, and data structures with JSON::PP. I tried to focus on ease of use and documentation.


This module posts messages to the Discord chat service, using their Webhook interface. Webhooks are a simple way to add post-only functions to external clients, without the need to create a full-fledged client or "bot".

Normally, Webhooks are used to issue a notification to chat channels when an external event from another site or service occurs, e.g. when a commit is made to a Git repository, a story is posted to a news site, or a player is fragged in a game.

An example Discord Webhook URL looks like this:

https://discordapp.com/api/webhooks/2237...5344/3d89...cf11

where the first magic number ("2237...5344") is the id and the second ("3d89...cf11") is the token.

For more information on Discord Webhooks, see the Discord API documentation located at https://discordapp.com/developers/docs/resources/webhook.

greg-kennedy@github 0 comments