public static void Log(string module, string text, ConsoleColor?msgForegroundColor = null, ConsoleColor?msgBackgroundColor = null)
 {
     PrettyPrint.Write($" [TerrariaChatRelay] | [{module}]: ", ConsoleColor.DarkCyan);
     SetColor(msgForegroundColor, msgBackgroundColor);
     Console.WriteLine(text);
     Console.ResetColor();
 }
        /// <summary>
        /// Generates a legacy request. Sends the content to the requested Uri,
        /// and returns the response.
        /// </summary>
        /// <param name="uri">Uri endpoint to send content to.</param>
        /// <param name="headers">Headers to be included when sending the content.</param>
        /// <param name="methodType">Method type of the request. Examples: POST, GET, PUT, etc.</param>
        /// <param name="contentType">The content's type.</param>
        /// <param name="content">Byte array content to be sent</param>
        /// <returns>String response from server.</returns>
        public static async Task <string> SendRequestAsync(Uri uri, WebHeaderCollection headers, string methodType, string contentType, byte[] content)
        {
            HttpWebRequest webRequest = HttpWebRequest.CreateHttp(uri);

            webRequest.Method        = methodType;
            webRequest.ContentType   = contentType;
            webRequest.ContentLength = content.Length;

            // HttpWebRequest.CreateHttp adds it's own keys. Instead of overwriting them, we'll add onto them.
            foreach (var header in headers.AllKeys)
            {
                webRequest.Headers.Add($"{header}: {headers[header]}");
            }

            try
            {
                var reqStream = await webRequest.GetRequestStreamAsync().ConfigureAwait(false);

                reqStream.Write(content, 0, content.Length);

                var res = await webRequest.GetResponseAsync().ConfigureAwait(false);

                using (StreamReader sr = new StreamReader(res.GetResponseStream()))
                {
                    return(sr.ReadToEnd());
                }
            }
            catch (Exception e)
            {
                PrettyPrint.Log(e.Message);
            }

            return(null);
        }