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...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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