View on GitHub

Discord.4d

Send message to Discord using 4D

WebhookClient

Webhooks are a low-effort way to post messages to channels in Discord.

A Webhook provide an url which contains id and token.

https://discordapp.com/api/webhooks/<id>/<token>

Create a client

Using the url

$hook:=Discord .WebhookClient.new("https://discordapp.com/api/webhooks/<id>/<token>")

Using the id and token

$hook:=Discord .WebhookClient.new("<id>";"<token>")

or

$config:=New object("id"; "<id>"; "token"; "<token>") // Could be read from configuration file
$hook:=Discord .WebhookClient.new(config)

Send a message

$hook.send("Hello World")

or an embed message

$exampleEmbed:=Discord .MessageEmbed.new()
$exampleEmbed.setColor(16483663)\
.setTitle("Some title")\
.setURL("https://4d.com/")\
.addField(New object("name";"my field";"value";"Some value here"))

$result:=$hook.send($exampleEmbed)

For more fancy stuff see MessageEmbed

Get webhook information

See Webhook documentation