Skip to content
@jennifer/discord

discord cheatsheet

Every export of @jennifer/discord. Background is in the introduction.

jennifer
import "@jennifer/discord/" as discord;
import "http.j" as http;

Both sends POST JSON to the webhook URL and return the http.Response unchecked: 204 on success, 404 for a deleted webhook. A URL that is not https:// (or http:// to a loopback host) throws discord; transport failures throw from http.

Types

Message

FieldMeaning
content as stringmessage text; "" to omit
embeds as list of Embedthe embeds, in order
username as stringdisplay name override; "" for none
avatar as stringavatar image URL override; "" for none
allowedMentions as stringrendered allowed_mentions object; "" for Discord's default

Embed

FieldMeaning
title as stringembed title
description as stringembed body
color as intleft-bar colour, decimal RGB
fields as list of stringrendered field objects
footer as stringrendered footer object; "" for none
author as stringrendered author object; "" for none

Sending

FunctionReturnsSends
discord.send(webhookUrl, content)http.Response{"content": ...}
discord.sendMessage(webhookUrl, m)http.Responserender(m)

Building

FunctionReturnsDoes
discord.message()Messagean empty message
discord.content(m, content)Messagesets the text
discord.username(m, name)Messagesets the display name override
discord.avatar(m, url)Messagesets the avatar override
discord.noMentions(m)Messagesets allowed_mentions so nobody is notified
discord.embed(m, title, description, color)Messageappends an embed; throws discord for a colour outside 0 to 16777215
discord.embedField(m, name, value, inline)Messageadds a field to the latest embed; throws discord without one
discord.embedFooter(m, text)Messagesets the latest embed's footer; throws discord without one
discord.embedAuthor(m, name)Messagesets the latest embed's author; throws discord without one
discord.render(m)stringthe JSON payload