redditwarp.siteprocs.moderation.SYNC#

class redditwarp.siteprocs.moderation.SYNC.ModerationProcedures(client: Client)[source]#

Bases: object

legacy: Legacy#

Legacy procedures for retrieving subreddit users.

pull_users: PullUsers#

Procedures for retrieving subreddit users.

pull: Pull#

Procedures for pulling moderation items.

note: Note#

Procedures for managing mod notes.

pull_actions(sr: str, amount: int | None = None, *, action: str = '', mod: str = '') ImpartedPaginatorChainingIterator[ModerationActionLogPaginator, ModerationActionLogEntry][source]#

Retrieve recent moderation actions from the mod log.

Hint

Moderator actions taken within a subreddit are logged to a mod log. Entries in the mod log last for 3 months before they become inaccessible.

Parameters:
  • sr (str) – The target subreddit.

  • amount (Optional[int]) – The number of items to retrieve.

  • action (str) – Limit log entries to only those of a specified action.

  • mod (str) – A comma-delimited list of moderator names to restrict the results to, or use the string a to restrict the results to actions performed by administrators.

Return type:

ImpartedPaginatorChainingIterator[ModerationActionLogPaginator, ModerationActionLogEntry]

Raises:

redditwarp.http.exceptions.StatusCodeException

  • 404:

    You do not have permission to view the mod log of the specified subreddit.

get_moderator(sr: str, user: str) Moderator | None[source]#

Behaves similarly to get_approved_user().

get_moderator_invitation(sr: str, user: str) Moderator | None[source]#

Behaves similarly to get_approved_user().

get_editable_moderator(sr: str, user: str) Moderator | None[source]#

Behaves similarly to get_approved_user().

get_approved_user(sr: str, user: str) ApprovedUser | None[source]#

Get an approved user of a subreddit.

Parameters:
  • sr (str) – Name of a subreddit.

  • user (str) – Name of a user.

Return type:

Optional[ApprovedUser]

Raises:

redditwarp.exceptions.RedditError

  • SUBREDDIT_NOEXIST:

    The target subreddit does not exist.

  • SUBREDDIT_NO_ACCESS:

    The subreddit cannot be accessed.

get_banned_user(sr: str, user: str) BannedUser | None[source]#

Behaves similarly to get_approved_user().

get_muted_user(sr: str, user: str) MutedUser | None[source]#

Behaves similarly to get_approved_user().

send_moderator_invite(sr: str, user: str, permissions: Sequence[str]) None[source]#

Send a moderator invite.

If the user is already invited, nothing happens. The permissions won’t change.

Parameters:
  • sr (str) –

  • user (str) –

  • permissions (Sequence[str]) –

    Values: all, access, chat_config, chat_operator, config, flair, mail, posts, wiki.

    Pass an empty sequence for no permissions.

Return type:

None

Raises:
  • redditwarp.exceptions.RedditError

    • USER_REQUIRED:

      There is no user context.

    • NO_USER:

      The user parameter was empty, or contains invalid characters.

    • USER_DOESNT_EXIST:

      The user specified by user does not exist.

    • INVALID_PERMISSIONS:

      An invalid permission was provided.

    • ALREADY_MODERATOR:

      The user is already a moderator.

  • redditwarp.http.exceptions.StatusCodeException

    • 403:
      • You don’t have permission.

      • The target subreddit specified was empty.

    • 404:

      The specified subreddit does not exist.

accept_moderator_invite(sr: str) None[source]#

Accept a moderator invite.

Parameters:

sr (str) –

Return type:

None

Raises:
revoke_moderator_invite(sr: str, user: str) None[source]#

Revoke a moderator invite.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

Raises:
remove_moderator(sr: str, user: str) None[source]#

Remove a moderator.

Nothing happens if the specified user is not a moderator of the subreddit.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

Raises:
leave_moderator(sr_id: int | str) None[source]#

Abdicate moderator status in a subreddit.

Warning

This action cannot be undone.

Be careful with this endpoint. It’s possible for a subreddit to not have any moderators.

Nothing happens if the specified subreddit ID is not valid or the current user is not a moderator of the subreddit.

Parameters:

sr_id (Union[int, str]) –

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

set_moderator_permissions(sr: str, user: str, permissions: Sequence[str]) None[source]#

Set the permissions of a moderator.

Be careful with this endpoint. It’s possible for a subreddit to not have any moderators.

Nothing happens if the current user is not a moderator of the subreddit.

Parameters:
  • sr (str) –

  • user (str) –

  • permissions (Sequence[str]) –

    Values: all, access, chat_config, chat_operator, config, flair, mail, posts, wiki.

    Pass an empty sequence for no permissions.

Return type:

None

Raises:
  • redditwarp.exceptions.RedditError

    • USER_REQUIRED:

      There is no user context.

    • NO_USER:

      The user parameter was empty, or contains invalid characters.

    • USER_DOESNT_EXIST:

      The user specified by user does not exist.

    • INVALID_PERMISSION_TYPE:

      The user specified by user isn’t a moderator of the subreddit.

  • redditwarp.http.exceptions.StatusCodeException

    • 403:

      You don’t have permission.

    • 404:

      The specified subreddit does not exist.

set_moderator_invite_permissions(sr: str, user: str, permissions: Sequence[str]) None[source]#

Set the permissions on a moderator invite.

Parameters:
  • sr (str) –

  • user (str) –

  • permissions (Sequence[str]) –

    Values: all, access, chat_config, chat_operator, config, flair, mail, posts, wiki.

    Pass an empty sequence for no permissions.

Return type:

None

Raises:
  • redditwarp.exceptions.RedditError

    • USER_REQUIRED:

      There is no user context.

    • NO_USER:

      The user parameter was empty, or contains invalid characters.

    • USER_DOESNT_EXIST:

      The user specified by user does not exist.

    • INVALID_PERMISSION_TYPE:

      The user specified by user doesn’t have a moderator invite to the subreddit.

  • redditwarp.http.exceptions.StatusCodeException

    • 403:

      You don’t have permission.

    • 404:

      The specified subreddit does not exist.

add_approved_user(sr: str, user: str) None[source]#

Add an approved user to a subreddit.

If the user is already an approved user, nothing happens.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

Raises:
remove_approved_user(sr: str, user: str) None[source]#

Remove an approved user of a subreddit.

If the user is already not an approved user, nothing happens.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

Raises:
  • redditwarp.exceptions.RedditError

    • USER_REQUIRED:

      There is no user context.

    • NO_USER:

      The user parameter was empty, or contains invalid characters.

    • USER_DOESNT_EXIST:

      The user specified by user does not exist.

  • redditwarp.http.exceptions.StatusCodeException

    • 400:

      The user parameter was empty or the user doesn’t exist.

    • 403:
      • You don’t have permission.

      • The target subreddit specified was empty.

    • 404:

      The specified subreddit does not exist.

leave_approved_user(sr_id: int | str) None[source]#

Abdicate approved user status in a subreddit.

Nothing happens if the specified subreddit ID is not valid or the current user is not an approved user of the subreddit.

Parameters:

sr_id (Union[int, str]) –

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

ban_user(sr: str, user: str, *, duration: int | None = None, reason: str = '', note: str = '', message: str = '') None[source]#

Ban a user from a subreddit.

Banning an already banned user does nothing. However, when banning an already banned user (as to change the ban reason or note), if the duration is changed then a new direct message will be issued to the user informing them of the duration change.

Parameters:
  • sr (str) –

  • user (str) –

  • duration (Optional[int]) –

    Number of days they should be banned for, in the range of 1 to 999.

    To change the duration of a ban, re-issue this procedure with a new duration. A direct message is sent to the user informing them of the ban duration change.

  • reason (str) – Ban reason. No longer than 100 characters.

  • note (str) – A moderator note. No longer than 300 characters.

  • message (str) –

    The message to include in the DM that is sent to the user.

    Specify markdown text.

    Note that a direct message is always sent to the banned user when a ban is issued. The ban message shows in the DM under a section called “Note from the moderators:”.

    If empty string, no message or section “Note from the moderators:” is shown.

Return type:

None

Raises:
  • redditwarp.exceptions.RedditError

    • USER_REQUIRED:

      There is no user context.

    • NO_USER:

      The user parameter was empty, or contains invalid characters.

    • USER_DOESNT_EXIST:

      The user specified by user does not exist.

    • BAD_NUMBER:

      When type: banned or type: wikibanned, the number specified by duration is not within the range 1 to 999.

    • TOO_LONG:
      • The value specified by reason is over 100 characters.

      • The value specified by note is over 300 characters.

  • redditwarp.http.exceptions.StatusCodeException

    • 403:
      • You don’t have permission.

      • The target subreddit specified was empty.

    • 404:

      The specified subreddit does not exist.

unban_user(sr: str, user: str) None[source]#

Unban a user from a subreddit.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

(raises):

Same as remove_approved_user().

mute_user(sr: str, user: str, *, note: str = '') None[source]#

Mute a user in a subreddit.

Muting an already muted user does nothing.

Parameters:
  • sr (str) –

  • user (str) –

  • note (str) – A moderator note. No longer than 300 characters.

Return type:

None

Raises:
unmute_user(sr: str, user: str) None[source]#

Unmute a user in a subreddit.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

(raises):

Same as remove_approved_user().

add_wiki_contributor(sr: str, user: str) None[source]#

Add a wiki contributor in a subreddit.

Adding a user who is already a wiki contributor does nothing.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

(raises):

Same as add_approved_user().

remove_wiki_contributor(sr: str, user: str) None[source]#

Remove a wiki contributor in a subreddit.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

(raises):

Same as remove_approved_user().

ban_wiki_contributor(sr: str, user: str, *, duration: int | None = None, reason: str = '', note: str = '') None[source]#

Ban a wiki contributor in a subreddit.

Adding a user who is already a wiki contributor does nothing.

Parameters:
  • sr (str) –

  • user (str) –

  • duration (Optional[int]) – Number of days they should be banned for, in the range of 1 to 999.

  • reason (str) – Ban reason. No longer than 100 characters.

  • note (str) – A moderator note. No longer than 300 characters.

Return type:

None

Raises:
unban_wiki_contributor(sr: str, user: str) None[source]#

Unban a wiki contributor in a subreddit.

Parameters:
  • sr (str) –

  • user (str) –

Return type:

None

(raises):

Same as remove_approved_user().

class RemovalReason(outer: ModerationProcedures)[source]#

Bases: object

create(sr: str, title: str, message: str) str[source]#

Create a removal reason.

Parameters:
  • sr (str) –

  • title (str) – A title for this removal reason.

  • message (str) – The removal reason message.

Returns:

The newly created removal reason ID.

Return type:

str

Raises:
  • redditwarp.exceptions.RedditError

    • MOD_REQUIRED:
      • There is no user context.

      • The current user is not a moderator of the subreddit.

    • NO_TEXT:
      • The title parameter was not specified or was empty.

      • The message parameter was not specified or was empty.

    • TOO_LONG:
      • The value specified for title is over 50 characters.

      • The value specified for message is over 10000 characters.

  • redditwarp.http.exceptions.StatusCodeException

    • 500:

      The target subreddit does not exist.

retrieve(sr: str) Mapping[str, tuple[str, str]][source]#

Get a list of removal reasons.

Parameters:

sr (str) –

Returns:

A mapping of removal reason IDs to tuples of (title, message).

Return type:

Mapping[str, tuple[str, str]]

Raises:

redditwarp.exceptions.RedditError

  • MOD_REQUIRED:
    • There is no user context.

    • The current user is not a moderator of the subreddit.

  • SUBREDDIT_NOEXIST:

    The target subreddit does not exist.

replace(sr: str, idt: str, title: str, message: str) None[source]#

Update a removal reason’s title and message.

Both parameters title and message must be specified otherwise a NO_TEXT API error is returned.

Parameters:
  • sr (str) –

  • idt (str) – A removal reason ID.

  • title (str) –

  • message (str) –

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • MOD_REQUIRED:
    • There is no user context.

    • The current user is not a moderator of the subreddit.

  • SUBREDDIT_NOEXIST:

    The target subreddit does not exist.

  • INVALID_ID:

    The specified removal reason ID was not found.

  • NO_TEXT:
    • The title parameter was not specified or was empty.

    • The message parameter was not specified or was empty.

  • TOO_LONG:
    • The value specified for title is over 50 characters.

    • The value specified for message is over 10000 characters.

delete(sr: str, idt: str) None[source]#

Delete a removal reason.

If the specified removal reason ID did not exist, nothing happens.

Parameters:
  • sr (str) –

  • idt (str) –

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • MOD_REQUIRED:
    • There is no user context.

    • The current user is not a moderator of the subreddit.

  • SUBREDDIT_NOEXIST:

    The target subreddit does not exist.

  • INVALID_ID:

    The specified removal reason ID was not found.

property removal_reason: None#

Manage subreddit removal reasons.