SubredditStylesheet

class asyncpraw.models.reddit.subreddit.SubredditStylesheet(subreddit)

Provides a set of stylesheet functions to a Subreddit.

For example, to add the css data .test{color:blue} to the existing stylesheet:

subreddit = await reddit.subreddit("test")
stylesheet = await subreddit.stylesheet()
stylesheet.stylesheet.stylesheet += ".test{color:blue}"
await subreddit.stylesheet.update(stylesheet.stylesheet)
Parameters:

subreddit (asyncpraw.models.Subreddit)

await __call__()

Return the Subreddit’s stylesheet.

To be used as:

subreddit = await reddit.subreddit("test")
stylesheet = await subreddit.stylesheet()
Return type:

Stylesheet

__init__(subreddit)

Initialize a SubredditStylesheet instance.

Parameters:

subreddit (Subreddit) – The Subreddit associated with the stylesheet.

Return type:

None

An instance of this class is provided as:

subreddit = await reddit.subreddit("test")
subreddit.stylesheet
await delete_banner()

Remove the current Subreddit (redesign) banner image.

Succeeds even if there is no banner image.

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.delete_banner()
Return type:

None

await delete_banner_additional_image()

Remove the current Subreddit (redesign) banner additional image.

Succeeds even if there is no additional image. Will also delete any configured hover image.

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.delete_banner_additional_image()
Return type:

None

await delete_banner_hover_image()

Remove the current Subreddit (redesign) banner hover image.

Succeeds even if there is no hover image.

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.delete_banner_hover_image()
Return type:

None

await delete_header()

Remove the current Subreddit header image.

Succeeds even if there is no header image.

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.delete_header()
Return type:

None

await delete_image(name)

Remove the named image from the Subreddit.

Succeeds even if the named image does not exist.

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.delete_image("smile")
Return type:

None

Parameters:

name (str)

await delete_mobile_banner()

Remove the current Subreddit (redesign) mobile banner.

Succeeds even if there is no mobile banner.

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.delete_banner_hover_image()
Return type:

None

await delete_mobile_header()

Remove the current Subreddit mobile header.

Succeeds even if there is no mobile header.

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.delete_mobile_header()
Return type:

None

await delete_mobile_icon()

Remove the current Subreddit mobile icon.

Succeeds even if there is no mobile icon.

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.delete_mobile_icon()
Return type:

None

await update(stylesheet, *, reason=None)

Update the Subreddit’s stylesheet.

Parameters:
  • stylesheet (str) – The CSS for the new stylesheet.

  • reason (str | None) – The reason for updating the stylesheet.

Return type:

None

For example:

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.update("p { color: green; }", reason="color text green")
await upload(media, /, *, name)

Upload an image to the Subreddit.

Parameters:
  • media (StylesheetImage) – The StylesheetImage to upload.

  • name (str) – The name to use for the image. If an image already exists with the same name, it will be replaced.

Return type:

dict[str, str]

Returns:

A dictionary containing a link to the uploaded image under the key img_src.

Raises:

asyncprawcore.TooLarge if the overall request body is too large.

Raises:

RedditAPIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

For example:

from asyncpraw.models import StylesheetImage

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.upload(StylesheetImage("img.png"), name="smile")
await upload_banner(media, /)

Upload an image for the Subreddit’s (redesign) banner image.

Parameters:

media (StylesheetAsset) – The StylesheetAsset to upload.

Raises:

asyncprawcore.TooLarge if the overall request body is too large.

Raises:

RedditAPIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Return type:

None

For example:

from asyncpraw.models import StylesheetAsset

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.upload_banner(StylesheetAsset("banner.png"))
await upload_banner_additional_image(media, /, *, align=None)

Upload an image for the Subreddit’s (redesign) additional image.

Parameters:
Raises:

asyncprawcore.TooLarge if the overall request body is too large.

Raises:

RedditAPIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Return type:

None

For example:

from asyncpraw.models import StylesheetAsset

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.upload_banner_additional_image(StylesheetAsset("banner.png"))
await upload_banner_hover_image(media, /)

Upload an image for the Subreddit’s (redesign) additional image.

Parameters:

media (StylesheetAsset) – The StylesheetAsset to upload.

Return type:

None

Fails if the Subreddit does not have an additional image defined.

Raises:

asyncprawcore.TooLarge if the overall request body is too large.

Raises:

RedditAPIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Parameters:

media (StylesheetAsset)

Return type:

None

For example:

from asyncpraw.models import StylesheetAsset

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.upload_banner_hover_image(StylesheetAsset("banner.png"))
await upload_header(media, /)

Upload an image to be used as the Subreddit’s header image.

Parameters:

media (StylesheetImage) – The StylesheetImage to upload.

Return type:

dict[str, str]

Returns:

A dictionary containing a link to the uploaded image under the key img_src.

Raises:

asyncprawcore.TooLarge if the overall request body is too large.

Raises:

RedditAPIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

For example:

from asyncpraw.models import StylesheetImage

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.upload_header(StylesheetImage("header.png"))
await upload_mobile_banner(media, /)

Upload an image for the Subreddit’s (redesign) mobile banner.

Parameters:

media (StylesheetAsset) – The StylesheetAsset to upload.

Return type:

None

For example:

from asyncpraw.models import StylesheetAsset

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.upload_mobile_banner(StylesheetAsset("banner.png"))

Fails if the Subreddit does not have an additional image defined.

Raises:

prawcore.TooLarge if the overall request body is too large.

Raises:

RedditAPIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Parameters:

media (StylesheetAsset)

Return type:

None

await upload_mobile_header(media, /)

Upload an image to be used as the Subreddit’s mobile header.

Parameters:

media (StylesheetImage) – The StylesheetImage to upload.

Return type:

dict[str, str]

Returns:

A dictionary containing a link to the uploaded image under the key img_src.

Raises:

asyncprawcore.TooLarge if the overall request body is too large.

Raises:

RedditAPIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

For example:

from asyncpraw.models import StylesheetImage

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.upload_mobile_header(StylesheetImage("header.png"))
await upload_mobile_icon(media, /)

Upload an image to be used as the Subreddit’s mobile icon.

Parameters:

media (StylesheetImage) – The StylesheetImage to upload.

Return type:

dict[str, str]

Returns:

A dictionary containing a link to the uploaded image under the key img_src.

Raises:

asyncprawcore.TooLarge if the overall request body is too large.

Raises:

RedditAPIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

For example:

from asyncpraw.models import StylesheetImage

subreddit = await reddit.subreddit("test")
await subreddit.stylesheet.upload_mobile_icon(StylesheetImage("icon.png"))