mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 11:21:47 -05:00
fix a bug
This commit is contained in:
parent
de6d1d15ab
commit
d40c527da1
1 changed files with 25 additions and 29 deletions
|
@ -121,36 +121,32 @@ internal static void ScreamToDiscord(string title, string desc, string url)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(conf.WebhookUrl))
|
if (!string.IsNullOrWhiteSpace(conf.WebhookUrl))
|
||||||
{
|
{
|
||||||
var wc = HttpWebRequest.Create(conf.WebhookUrl);
|
var httpWebRequest = (HttpWebRequest)WebRequest.Create(conf.WebhookUrl);
|
||||||
wc.Method = "POST";
|
httpWebRequest.ContentType = "application/json";
|
||||||
wc.ContentType = "application/json";
|
httpWebRequest.Method = "POST";
|
||||||
|
|
||||||
|
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
|
||||||
|
{
|
||||||
string json = new JavaScriptSerializer().Serialize(new
|
string json = new JavaScriptSerializer().Serialize(new
|
||||||
{
|
{
|
||||||
content = $@"**{title}**
|
content = $@"**{title}**
|
||||||
|
|
||||||
{desc}
|
{desc}
|
||||||
|
|
||||||
Visit this URL to see more: {url}"
|
Visit this URL for more info: {url}"
|
||||||
});
|
});
|
||||||
wc.ContentLength = json.Length;
|
|
||||||
using (var s = wc.GetRequestStream())
|
streamWriter.Write(json);
|
||||||
|
streamWriter.Flush();
|
||||||
|
streamWriter.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
|
||||||
|
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
|
||||||
{
|
{
|
||||||
using(var writer = new StreamWriter(s))
|
var result = streamReader.ReadToEnd();
|
||||||
{
|
}
|
||||||
writer.Write(json);
|
|
||||||
using(var r = wc.GetResponse())
|
|
||||||
{
|
|
||||||
using(var rs = r.GetResponseStream())
|
|
||||||
{
|
|
||||||
using(var reader = new StreamReader(rs))
|
|
||||||
{
|
|
||||||
string result = reader.ReadToEnd();
|
|
||||||
db.AuditLogs.Add(new AuditLog("system", AuditLogLevel.Admin, "Discord webhook sent. Result: " + result));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue