ModmailConversation

class asyncpraw.models.reddit.modmail.ModmailConversation(reddit: asyncpraw.Reddit, id: Optional[str] = None, mark_read: bool = False, _data: Optional[Dict[str, Any]] = None)

A class for modmail conversations.

Typical Attributes

Note

This table describes attributes that typically belong to objects of this class. Async PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, Async PRAW makes no effort to document any new/removed/changed attributes, other than to instruct you on how to discover what is available. As a result, this table of attributes may not be complete. See Determine Available Attributes of an Object for detailed information.

If you would like to add an attribute to this table, feel free to open a pull request.

Attribute

Description

authors

Provides an ordered list of Redditor instances. The authors of each message in the modmail conversation.

id

The ID of the ModmailConversation.

is_highlighted

Whether or not the ModmailConversation is highlighted.

is_internal

Whether or not the ModmailConversation is a private mod conversation.

last_mod_update

Time of the last mod message reply, represented in the ISO 8601 standard with timezone.

last_updated

Time of the last message reply, represented in the ISO 8601 standard with timezone.

last_user_update

Time of the last user message reply, represented in the ISO 8601 standard with timezone.

num_messages

The number of messages in the ModmailConversation.

obj_ids

Provides a list of dictionaries representing mod actions on the ModmailConversation. Each dict contains attributes of "key" and "id". The key can be either ""messages" or "ModAction". "ModAction" represents archiving/highlighting etc.

owner

Provides an instance of Subreddit. The subreddit that the ModmailConversation belongs to.

participant

Provides an instance of Redditor. The participating user in the ModmailConversation.

subject

The subject of the ModmailConversation.

__init__(reddit: asyncpraw.Reddit, id: Optional[str] = None, mark_read: bool = False, _data: Optional[Dict[str, Any]] = None)

Initialize a ModmailConversation instance.

Parameters

mark_read – If True, conversation is marked as read (default: False).

await archive()

Archive the conversation.

For example:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail("2gmz")
await conversation.archive()
await highlight()

Highlight the conversation.

For example:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail("2gmz")
await conversation.highlight()
await load()

Re-fetches the object.

This is used to explicitly fetch or re-fetch the object from reddit. This method can be used on any RedditBase object.

await reddit_base_object.load()
await mute(num_days=3)

Mute the non-mod user associated with the conversation.

Parameters

num_days – Duration of mute in days. Valid options are 3, 7, or 28 (default: 3).

For example:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail("2gmz")
await conversation.mute()

To mute for 7 days:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail("2gmz")
await conversation.mute(7)
classmethod parse(data: Dict[str, Any], reddit: asyncpraw.Reddit, convert_objects: bool = True)

Return an instance of ModmailConversation from data.

Parameters
  • data – The structured data.

  • reddit – An instance of Reddit.

  • convert_objects – If True, convert message and mod action data into objects (default: True).

await read(other_conversations: Optional[List[ModmailConversation]] = None)

Mark the conversation(s) as read.

Parameters

other_conversations – A list of other conversations to mark (default: None).

For example, to mark the conversation as read along with other recent conversations from the same user:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail.conversation("2gmz")
await conversation.read(other_conversations=conversation.user.recent_convos)
await reply(body: str, author_hidden: bool = False, internal: bool = False)

Reply to the conversation.

Parameters
  • body – The Markdown formatted content for a message.

  • author_hidden – When True, author is hidden from non-moderators (default: False).

  • internal – When True, message is a private moderator note, hidden from non-moderators (default: False).

Returns

A ModmailMessage object for the newly created message.

For example, to reply to the non-mod user while hiding your username:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail("2gmz")
await conversation.reply("Message body", author_hidden=True)

To create a private moderator note on the conversation:

await conversation.reply("Message body", internal=True)
await unarchive()

Unarchive the conversation.

For example:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail("2gmz")
await conversation.unarchive()
await unhighlight()

Un-highlight the conversation.

For example:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail("2gmz")
await conversation.unhighlight()
await unmute()

Unmute the non-mod user associated with the conversation.

For example:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail("2gmz")
await conversation.unmute()
await unread(other_conversations: Optional[List[ModmailConversation]] = None)

Mark the conversation(s) as unread.

Parameters

other_conversations – A list of other conversations to mark (default: None).

For example, to mark the conversation as unread along with other recent conversations from the same user:

subreddit = await reddit.subreddit("test")
conversation = await subreddit.modmail.conversation("2gmz")
await conversation.unread(other_conversations=conversation.user.recent_convos)