Skip to main content

A small library to style text for Discord without having to remember any syntax

Project description

discord-styled-text

A small library to style text for Discord without having to remember any syntax

PyPI PyPI - Python Version PyPI - License Documentation Status

Installation

discord-styled-text requires Python 3.6 at minimum.

$ pip install discord-styled-text

Documentation

Documentation is available on ReadTheDocs.

Example Usage

>>> from discord_styler import *

>>> bold_text = Bold("Here's some bold text")
>>> italic_text = Italic("and here's some", Underline("italic text"), "with nested styles!")
>>> text = StyledText("We can combine them:", bold_text, italic_text)
>>> str(text)
"We can combine them: **Here's some bold text** *and here's some __italic text__ with nested styles!*"

>>> quoted = StyledText(BlockQuote(text), "and we can do quotes too")
>>> str(quoted)
"> We can combine them: **Here's some bold text** *and here's some __italic text__ with nested styles!*\n and we can do quotes too"

>>> question = StyledText(
...     UserMention(200102491231092736),
...     f"will you be free at {TimeStamp(1618953630, TimeStyle.LongDateTime)}?",
...     f"I'll be doing code review in {ChannelMention(656893570711814145)} if you wanna join")
>>> str(question)
"<@200102491231092736> will you be free at <t:1618953630:F>? I'll be doing code review in <#656893570711814145> if you wanna join"

>>> link = NonEmbeddingURL("https://github.com/miaowware/discord-styled-text/pull/1")
>>> str(link)
'<https://github.com/miaowware/discord-styled-text/pull/1>'

>>> code = StyledText(
...     "What do you think of this?\n",
...     CodeBlock('def __str__(self) -> str:\n        return "||" + super().__str__() + "||"', lang="py"))
>>> str(code)
'What do you think of this?\n ```py\ndef __str__(self) -> str:\n        return "||" + super().__str__() + "||"\n```'

The output of the example, rendered in Discord

Copyright

Copyright 2021 classabbyamp, 0x5c
Released under the BSD 3-Clause License.
See LICENSE for the full license text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discord-styled-text-1.0.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

discord_styled_text-1.0.0-py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page