void ProcessDiscordComLink()
{
Puts($"Processing and sending {discordChatMessages.Count} chat messages to discord");
HttpClient client = new HttpClient();
foreach (tacti.DiscordChatMessage message in discordChatMessages)
{
Dictionary<string, string> data = new Dictionary<string, string>()
{
{"username", message.playerName},
{"content", message.datetime.ToShortTimeString() + " (UTC): " + message.message }
};
client.PostAsync("Insert discord api link here", new FormUrlEncodedContent(data));
}
discordChatMessages.Clear();
}
//Where discordChatMessages is a chat message buffer
Thats the method the error comes in
(I know there're most likely is a plugin already made for this or what ever but I wanted to do it my self)
Merged postError while compiling: TactiPLugin.cs(1850,24): error CS0023: The `.' operator cannot be applied to operand of type `System.Net.Http.HttpClient'
Merged post"[SERVER v1.0.24] Console: TactiPLugin.cs(1834,13): error CS1070: The type `System.Net.Http.HttpClient' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'"
Right... So I guess I've to use a ortherway to make a http post request then`?
Merged postAnd using System.Net webRequest makes the exception:
(UnauthorizedAccessException: System access is restricted, you are not allowed to use System.Net.HttpWebRequest)
): So is that umod blocking that or is it something else?
Merged posthttps://umod.org/documentation/api/web-requestsMerged postAlrighty then should have seached on the umod docs first...
So now I need a way to encode a string to be (post friendly) aka WebUtility.UrlEncode does exactly what I want but I'm not allowed to use it ):