Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def spoiler(self):
"""
Mark the item as a spoiler.
Returns
-------
resp: Dict
The API response JSON.
"""
return await self.reddit.post_request(API_PATH["post_spoiler"], id=self.fullname)
Send a message to the subreddit.
Parameters
----------
subject: str
The message subject.
text: str
The message contents as markdown.
from_sr: str or Subreddit
The subreddit the message is being sent from if applicable.
Returns
-------
response: Dict
The API response JSON as a dictionary.
"""
return await self._reddit.message(API_PATH["subreddit"].format(sub=self.display_name), subject, text,
str(from_sr))
async def unignore_reports(self):
"""
Unignore previously ignored reports on the Reddit item.
Returns
-------
resp: Dict
The API response JSON.
"""
return await self.reddit.post_request(API_PATH["mod_unignore_reports"], id=self.fullname)
async def revert(self, revision: Union[str, 'WikipageRevision']):
resp = await self.subreddit._reddit.post_request(
API_PATH["wiki_revert"].format(sub=self.subreddit), data={
"page": self.name,
"revision": str(revision)
})
return resp if resp else True
async def downvote(self):
"""
Downvote the item.
Returns
-------
resp: Dict
The API response JSON.
"""
return await self.reddit.post_request(API_PATH["post_vote"], id=self.fullname, dir=-1)
async def conversations(self) -> 'ModmailConversation':
"""
Retrieve a list of modmail conversations.
Yields
------
conversation: ModmailConversation
A modmail conversation held in the subreddit.
"""
req = await self.subreddit.reddit.get_request(API_PATH["modmail_conversations"],
entity=self.subreddit.display_name)
for id in req["conversations"]:
yield ModmailConversation(self.subreddit.reddit, req["conversations"][id])
async def unmark_nsfw(self):
"""
Unmark the item as NSFW.
Returns
-------
resp: Dict
The API response JSON.
"""
return await self.reddit.post_request(API_PATH["post_unmarknsfw"], id=self.fullname)
for comment in subreddit.mod.edited.stream():
print(comment)
Parameters
----------
kwargs: \*\*Dict
:class:`~apraw.models.ListingGenerator` ``kwargs``.
Returns
-------
generator: ListingGenerator
A :class:`~apraw.models.ListingGenerator` mapped to grab edited items.
"""
from ..helpers.generator import ListingGenerator
return ListingGenerator(self.subreddit._reddit,
API_PATH["subreddit_edited"].format(sub=self.subreddit.display_name),
subreddit=self.subreddit, *args, **kwargs)
async def delete(self):
"""
Delete the item.
Returns
-------
resp: Dict
The API response JSON.
"""
return await self.reddit.post_request(API_PATH["post_delete"], id=self.fullname)
async def show_comment(self):
"""
Mark a comment that it should not be collapsed because of crowd control.
The comment could still be collapsed for other reasons.
Returns
-------
resp: Dict
The API response JSON.
"""
return await self.reddit.post_request(API_PATH["mod_show_comment"], id=self.fullname)