Jump to content

Discord Webhook on task execution


Recommended Posts

This can be done with custom scripts.

import clr
clr.AddReference("System.Net")

from System.Net import HttpWebRequest, WebRequest
from System.Text import Encoding

webhookUrl = "WEBHOOK-URL-HERE"
name = "NAME-HERE"
message = "The server will restart in 5/10/15 minutes. bla bla"

data = "{ \"username\": \"" + name + "\", \"content\": \"" + message + "\" }"

bytes = Encoding.UTF8.GetBytes(data)

webRequest = WebRequest.Create(webhookUrl)

request = clr.Convert(webRequest, HttpWebRequest)
request.Method = "POST"
request.ContentType = "application/json"
request.ContentLength = bytes.Length

stream = request.GetRequestStream()
stream.Write(bytes, 0, bytes.Length)
stream.Close()

request.GetResponse()

 

Link to comment
Share on other sites

  • 1 year later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Who's Online   0 Members, 0 Anonymous, 70 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use