Skip to content

Instantly share code, notes, and snippets.

@sinancetinkaya
Last active April 5, 2020 00:45
Show Gist options
  • Save sinancetinkaya/a1a0ed903f8413731b006a0ae1bc0859 to your computer and use it in GitHub Desktop.
Save sinancetinkaya/a1a0ed903f8413731b006a0ae1bc0859 to your computer and use it in GitHub Desktop.
VBA discord webhook example
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