Hi,
I create simple library for sending messages to Discord over API. The source is in zip.
Discohook.zip (3.7 KB)
! You need JSONer library with V1.0.4 ( GitHub - Bikeprincess/BnR-JSONer · GitHub ).
To start use it, you need:
- the webhook for discord server channel
- create some vars:
-
VAR discordMsg : DiscordMsg_t; sendMsg : BOOL; sendMsgStatus : DiscohookSendMessage_e; msgBuffer : DiscohookMessageBuffer_t; DiscohookCore_0 : Discohook_Core; END_VAR VAR RETAIN Discohook : STRING[255] := '/api/webhooks/...'; END_VAR
-
- call CORE and send some messages
-
DiscohookCore_0(enable := TRUE, msgBuffer := msgBuffer); IF sendMsg THEN sendMsgStatus := Discohook_SendMessage(ADR(Discohook), ADR('Program:discordMsg'), msgBuffer); sendMsg := FALSE; END_IF;
-
The output can be something like this. You can use the emoticons used by discord :some_emo_text:.
The message is defined by structure of message (in my case DiscordMsg_t). You can edit structure of message by you. There (https://discohook.app) is cookbook how to create message. The JSONer take the name from struct and convert to JSON string, so be carefully, when changing the format.
Please give some feedback, when you use it ![]()
