Last active
April 5, 2020 00:45
-
-
Save sinancetinkaya/a1a0ed903f8413731b006a0ae1bc0859 to your computer and use it in GitHub Desktop.
VBA discord webhook example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function discord(message) | |
Set request = CreateObject("WinHttp.WinHttpRequest.5.1") | |
Dim Payload As String | |
DISCORD_WEBHOOK_URL = "https://discordapp.com/api/webhooks/{webhook_id}/{webhook_token}" | |
Payload = "content=" & message & _ | |
"&username=" & "{username}" & _ | |
"&avatar_url=" & "{avatar_url}" | |
With request | |
.Open "POST", DISCORD_WEBHOOK_URL, False | |
.setrequestHeader "Content-Type", "application/x-www-form-urlencoded" | |
.send Payload | |
End With | |
If request.Status <> 204 Then | |
discord = request.Status | |
Else | |
discord = message | |
End If | |
End Function | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment