redditwarp.siteprocs.subreddit.ASYNC#

class redditwarp.siteprocs.subreddit.ASYNC.SubredditProcedures(client: Client)[source]#

Bases: object

pull: Pull#

Pull subreddit submissions.

pulls: Pulls#

Pull subreddits.

async get(idy: int | str) Subreddit | None[source]#

Get information about a potentially inaccessible subreddit.

Parameters:

idy (Union[int, str]) –

Returns:

  • None if the subreddit does not exist, or the subreddit is private or banned.

  • Subreddit

Return type:

Optional[Subreddit]

async fetch(idy: int | str) Subreddit[source]#

Fetch information about a potentially inaccessible subreddit.

Parameters:

idy (Union[int, str]) –

Return type:

Subreddit

Raises:

redditwarp.exceptions.OperationException

  • The target subreddit is was not found.

  • The target subreddit is private or banned.

async get_by_name(name: str) Subreddit | None[source]#

Return information about a subreddit by name.

Returns None when the target subreddit is private or banned, or if the specified subreddit name contained invalid characters, or you specified the name of a special subreddit: all, popular, friends, mod.

Parameters:

name (str) – Subreddit name.

Return type:

Optional[Subreddit]

async fetch_by_name(name: str) Subreddit[source]#

Return information about a subreddit by name.

Behaves similarly to get_by_name().

Parameters:

name (str) – Subreddit name.

Return type:

Subreddit

Raises:
async get_potentially_inaccessible(idy: int | str) object | None[source]#

Get information about a potentially inaccessible subreddit.

Parameters:

idy (Union[int, str]) –

Returns:

Return type:

Optional[object]

async fetch_potentially_inaccessible(idy: int | str) object[source]#

Fetch information about a potentially inaccessible subreddit.

Parameters:

idy (Union[int, str]) –

Returns:

Return type:

Optional[object]

Raises:

redditwarp.exceptions.NoResultException – The target subreddit is was not found.

async get_potentially_inaccessible_by_name(name: str) object | None[source]#

Get information about a potentially inacessible subreddit.

Parameters:

name (str) –

Returns:

Return type:

Optional[object]

async fetch_potentially_inaccessible_by_name(name: str) object[source]#

Fetch information about a potentially inacessible subreddit.

Parameters:

name (str) –

Returns:

Return type:

object

Raises:

redditwarp.exceptions.NoResultException – The target subreddit is was not found.

bulk_fetch_potentially_inaccessible(ids: Iterable[_YIntOrStr]) CallChunkChainingAsyncIterator[object][source]#

Bulk fetch information about a potentially inacessible subreddits, by ID.

Any ID not found will be ignored.

Parameters:

ids (Iterable[_YIntOrStr]) –

Returns:

Iterator of:

Return type:

CallChunkChainingAsyncIterator[object]

bulk_fetch_potentially_inaccessible_by_name(names: Iterable[str]) CallChunkChainingAsyncIterator[object][source]#

Bulk fetch information about a potentially inacessible subreddits, by name.

Any name not found will be ignored.

Parameters:

ids (Iterable[int]) –

Returns:

Iterator of:

Return type:

CallChunkChainingAsyncIterator[object]

pull_new_comments(sr: str, amount: int | None = None) ImpartedPaginatorChainingAsyncIterator[LooseCommentListingAsyncPaginator, LooseComment][source]#

Pull new comments from a subreddit.

Parameters:
  • sr (str) –

  • amount (Optional[int]) –

Return type:

ImpartedPaginatorChainingAsyncIterator[LooseCommentListingAsyncPaginator, LooseComment]

async get_settings(sr: str) Mapping[str, Any][source]#

Get the settings of a subreddit.

Parameters:

sr (str) –

Return type:

Mapping[str, Any]

Raises:

redditwarp.http.exceptions.StatusCodeException

  • 302:

    The specified subreddit does not exist.

  • 404:
    • There is no user context.

    • You don’t have permission to view this subreddit’s settings.

async update_settings(idy: int | str, settings: Mapping[str, JSON_ro]) None[source]#

Update a subreddit’s settings.

Parameters:
  • idy (Union[int, str]) –

  • settings (Mapping[str, JSON_ro]) –

Return type:

None

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

  • SUBREDDIT_REQUIRED:

    The specified subreddit does not exist.

  • MOD_REQUIRED:

    The current user is not a moderator of the subreddit.

async subscribe_by_id(idy: int | str) None[source]#

Subscribe to a subreddit.

Parameters:

idy (Union[int, str]) –

Return type:

None

Raises:
async subscribe_by_name(name: str) None[source]#

Subscribe to a subreddit.

Parameters:

name (str) –

Return type:

None

Raises:
async unsubscribe_by_id(idy: int | str) None[source]#

Unsubscribe from a subreddit.

Behaves similarly to subscribe_by_id().

async unsubscribe_by_name(name: str) None[source]#

Unsubscribe from a subreddit.

Behaves similarly to subscribe_by_name().

async get_rules(sr: str) SubredditRules[source]#

Get a subreddit’s rules.

Example:

rules = await client.p.subreddit.get_rules(SR)
for i, rule in enumerate(rules, 1):
    print(f"{i}. {rule.short_name}\n{rule.description}\n")
Parameters:

sr (str) –

Return type:

SubredditRules

Raises:

redditwarp.http.exceptions.StatusCodeException

  • 404:

    The specified subreddit could not be accessed.

async get_post_requirements(sr: str) Mapping[str, Any][source]#

Get the post requirement settings of a subreddit.

Parameters:

sr (str) –

Return type:

Mapping[str, Any]

Raises:

redditwarp.exceptions.RedditError

  • USER_REQUIRED:

    There is no user context.

  • SUBREDDIT_NOEXIST:

    The specified subreddit does not exist.

  • SUBREDDIT_NO_ACCESS:

    The specified subreddit is private or banned.

search(query: str, amount: int | None = None) ImpartedPaginatorChainingAsyncIterator[SubredditSearchAsyncPaginator, Subreddit][source]#

Search subreddits by name or description.

Parameters:
  • query (str) –

  • amount (Optional[int]) –

Return type:

ImpartedPaginatorChainingAsyncIterator[SubredditSearchAsyncPaginator, Subreddit]

async search_names(name: str) Sequence[str][source]#

List subreddit names that begin with a query string.

Parameters:

name (str) –

Return type:

Sequence[str]

async exists(name: str) bool[source]#

Check whether a subreddit name exists.

An empty string returns true.

Parameters:

name (str) –

Return type:

bool

async get_similar_subreddits(idy: int | str, n: int | None = None) Sequence[Subreddit][source]#

Get a list of similar subreddits.

Parameters:
  • idy (Union[int, str]) –

  • n (Optional[int]) –

    The maximum number of entries to return.

    Effective default: 10.

Return type:

Sequence[Subreddit]