private StringContent GetPostFormattedJSON(RedditTextPost newPost) { // TODO : Check if post has image // TODO : Check if post has video // Title: New post on subreddit // URL: Title of post with link // Description: Content of post // Post Author: /u/Id // Content Warning: NSFW Or None var contentString = $"{{\"embeds\":[{{\"title\":\"{newPost.title}\",\"url\":\"{newPost.url}\",\"description\":\"{newPost.selftext}\",\"footer\":{{\"icon_url\":\"https://www.redditstatic.com/desktop2x/img/favicon/favicon-32x32.png\",\"text\":\"/u/{newPost.author}\",\"url\":\"https://reddit.com/r/EscapefromTarkov\"}}}}]}}"; return(new StringContent(contentString)); throw new NotImplementedException(); }
private async Task PostToWebHook(string webhook, RedditTextPost newPost) { try { var client = new HttpClient(); var content = GetPostFormattedJSON(newPost); var response = await client.PostAsync(webhook, content); Console.WriteLine(response); } catch (Exception ex) { #if DEBUG Console.WriteLine(ex); #endif _logger.LogError(ex.ToString()); } }