28 lines
842 B
Java
28 lines
842 B
Java
|
package xyz.etztech.minealert;
|
||
|
|
||
|
import java.io.OutputStream;
|
||
|
import java.net.HttpURLConnection;
|
||
|
import java.net.URL;
|
||
|
import java.net.URLConnection;
|
||
|
import java.nio.charset.StandardCharsets;
|
||
|
|
||
|
public class Webhook {
|
||
|
|
||
|
public static void send(String webhook, String embed) throws Exception {
|
||
|
URL url = new URL(webhook);
|
||
|
URLConnection con = url.openConnection();
|
||
|
HttpURLConnection http = (HttpURLConnection) con;
|
||
|
http.setRequestMethod("POST");
|
||
|
http.setDoOutput(true);
|
||
|
|
||
|
byte[] out = embed.getBytes(StandardCharsets.UTF_8);
|
||
|
int length = out.length;
|
||
|
http.setFixedLengthStreamingMode(length);
|
||
|
http.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
||
|
http.connect();
|
||
|
|
||
|
OutputStream os = http.getOutputStream();
|
||
|
os.write(out);
|
||
|
}
|
||
|
}
|