SubredditMessage

class praw.models.SubredditMessage(reddit: Reddit, _data: Dict[str, Any])

A class for messages to a subreddit.

__init__(reddit: Reddit, _data: Dict[str, Any])

Construct an instance of the Message object.

block()

Block the user who sent the item.

Note

This method pertains only to objects which were retrieved via the inbox.

Example usage:

comment = reddit.comment('dkk4qjd')
comment.block()

# or, identically:

comment.author.block()
collapse()

Mark the item as collapsed.

Note

This method pertains only to objects which were retrieved via the inbox.

Example usage:

inbox = reddit.inbox()

# select first inbox item and collapse it
message = next(inbox)
message.collapse()

See also uncollapse()

delete()

Delete the message.

Note

Reddit does not return an indication of whether or not the message was successfully deleted.

fullname

Return the object’s fullname.

A fullname is an object’s kind mapping like t3 followed by an underscore and the object’s base36 ID, e.g., t1_c5s96e0.

mark_read()

Mark a single inbox item as read.

Note

This method pertains only to objects which were retrieved via the inbox.

Example usage:

inbox = reddit.inbox.unread()

for message in inbox:
    # process unread messages

See also mark_unread()

To mark the whole inbox as read with a single network request, use praw.models.Inbox.mark_read()

mark_unread()

Mark the item as unread.

Note

This method pertains only to objects which were retrieved via the inbox.

Example usage:

inbox = reddit.inbox(limit=10)

for message in inbox:
    # process messages

See also mark_read()

mute()

Mute the sender of this SubredditMessage.

classmethod parse(data: Dict[str, Any], reddit: Reddit)

Return an instance of Message or SubredditMessage from data.

Parameters:
  • data – The structured data.
  • reddit – An instance of Reddit.
reply(body)

Reply to the object.

Parameters:body – The Markdown formatted content for a comment.
Returns:A Comment object for the newly created comment or None if Reddit doesn’t provide one.

A None value can be returned if the target is a comment or submission in a quarantined subreddit and the authenticated user has not opt-ed in to viewing the content. When this happens the comment will be sucessfully created on Reddit and can be retried by drawing the comment from the user’s comment history.

Example usage:

submission = reddit.submission(id='5or86n')
submission.reply('reply')

comment = reddit.comment(id='dxolpyc')
comment.reply('reply')
uncollapse()

Mark the item as uncollapsed.

Note

This method pertains only to objects which were retrieved via the inbox.

Example usage:

inbox = reddit.inbox()

# select first inbox item and uncollapse it
message = next(inbox)
message.uncollapse()

See also collapse()

unmute()

Unmute the sender of this SubredditMessage.