Skip to content

Commit 4e25f11

Browse files
committed
add del to comment objects
1 parent 6d6d530 commit 4e25f11

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

RedditSharp/Things/Comment.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ namespace RedditSharp.Things
1313
public class Comment : VotableThing
1414
{
1515
private const string CommentUrl = "/api/comment";
16-
private const string EditUserTextUrl = "/api/editusertext";
17-
private const string RemoveUrl = "/api/remove";
16+
private const string EditUserTextUrl = "/api/editusertext";
17+
private const string RemoveUrl = "/api/remove";
18+
private const string DelUrl = "/api/del";
1819
private const string SetAsReadUrl = "/api/read_message";
1920

2021
[JsonIgnore]
@@ -187,6 +188,28 @@ public void EditText(string newText)
187188
Body = newText;
188189
else
189190
throw new Exception("Error editing text.");
191+
}
192+
193+
private string SimpleAction(string endpoint)
194+
{
195+
if (Reddit.User == null)
196+
throw new AuthenticationException("No user logged in.");
197+
var request = WebAgent.CreatePost(endpoint);
198+
var stream = request.GetRequestStream();
199+
WebAgent.WritePostBody(stream, new
200+
{
201+
id = FullName,
202+
uh = Reddit.User.Modhash
203+
});
204+
stream.Close();
205+
var response = request.GetResponse();
206+
var data = WebAgent.GetResponseString(response.GetResponseStream());
207+
return data;
208+
}
209+
210+
public void Del()
211+
{
212+
var data = SimpleAction(DelUrl);
190213
}
191214

192215
public void Remove()

0 commit comments

Comments
 (0)