Skip to content

Instantly share code, notes, and snippets.

@rexs123
Created December 6, 2017 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rexs123/52e2fdb75a2a0c7f3a855c7173b4392b to your computer and use it in GitHub Desktop.
Save rexs123/52e2fdb75a2a0c7f3a855c7173b4392b to your computer and use it in GitHub Desktop.
<?php
function webhook($webhook, $url, $title, $description, $embedColor, $footerIcon, $footerText, $authorName, $iconUrl, $botName, $botAvatar, $content) {
if(isset($embedColor)) {
if(strpos($embedColor, "#") > -1) {
$c=str_replace("#", "", $embedColor);
if (!preg_match("/#([a-fA-F0-9]{3}){1,2}\b/", $c)) {
$color = hexdec( strtolower($c) );
}
}
} else {
$color = 0;
}
$sys["content"] = $content;
$sys["username"] = $botName;
$sys["avatar_url"] = $botAvatar;
$footer = array("icon_url" => $footerIcon, "text" => $footerText);
$author = array("url" => "", "name" => "$authorName", "icon_url" => $iconUrl);
$embed = array("url" => $url, "title" => $title, "description" => $description, "color" => $color, "footer" => $footer, "author" => $author);
$sys["embeds"] = array(0 => $embed);
$curl = curl_init($webhook);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($sys));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
}
$conn = new mysqli(DBHOST, DBUSER, DBPASS, DATABS);
if ($conn->connect_error) {
die("Oop's, Somethings broken!");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment