Skip to main content

DiscordBook

A Discord module for bot developers wanting a lightweight and customizable package for a book-like info display.

Example of a well-formatted book display:

Terminology:

  • Book - abstracted structure to use
  • Line - particular item inside the book - in the above example, "Abyssal Buckler" would be a line
  • Chapter - group of lines - in the example, "A" would be a chapter
  • Page - combination of chapter headers and lines that can be displayed on the embed

Options

Currently, 2 types of books are supported - a default book with the following default parameters:

Book(chapters = [], title = "\a", description = '\a', color = 1, image = None, per_page = 10)

Example usage of Book:

from discordbook import Book

# Creating the content for the book
lines1 = ["test line 1", "test line 2", "test line 3"]
chapter1 = Chapter("Test Chapter 1", lines1)

lines2 = ["test line 1", "test line 2", "test line 3"]
chapter2 = Chapter("Test Chapter 2", lines2)

lines3 = ["test line 1", "test line 2", "test line 3"]
chapter3 = Chapter("Test Chapter 3", lines3)

lines4 = ["test line 1", "test line 2", "test line 3"]
chapter4 = Chapter("Test Chapter 4", lines4)

lines5 = ["test line 1", "test line 2", "test line 3"]
chapter5 = Chapter("Test Chapter 5", lines5)

# Initializing the object itself
item_book = Book([chapter1, chapter2, chapter3, chapter4, chapter5], "Test Book", "Test book Desc")

# A blocking method that will send and constantly update the book display
await item_book.open_book(client, message.channel, message.author)

And an alphabetically ordered book with the following default parameters:

AlphabeticalBook(content = [], title = "\a", description = '\a', color = 1, per_page = 10, ignore_caps = True)

Example usage of Alphabetical Book:

from discordbook import AlphabeticalBook

# Creating the content for the book
lines1 = ["Test", "test", "Abc", "bc", "D", "Zee"]

# Initializing the object itself
a_book = AlphabeticalBook(lines1, "Test Book", "test desc", ignore_caps = False)

# A blocking method that will send and constantly update the book display
await a_book.open_book(client, message.channel)

Result

Caveats

  • Books are static once generated
  • Opening a book should be the last call in your function, since it will prevent the rest of your code from running
  • Creating a book with empty lines will result in errors

TODO:

  • Develop ordering of chapters based of less than function?
  • Bookmark feature to come back to this page after?
  • Give more fine-grained control with non-blocking books
  • Better error checking on small/empty books
  • Set browsing speed, better options for settings
  • Better documentation

Open to pull requests or issues!

Metadata

Release files for discordbook 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for discordbook 0.2.4
File Size Uploaded Provenance Actions
discordbook-0.2.4.tar.gz 5.0 kB Without provenance Details for discordbook-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for discordbook 0.2.4
File Interpreter ABI Platform Actions
discordbook-0.2.4-py3-none-any.whl Python 3 none any Details for discordbook-0.2.4-py3-none-any.whl

Total release size: 11.6 kB

Release files / discordbook-0.2.4.tar.gz

Download URL discordbook-0.2.4.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2bef455ec333b0d07c6078aa0e06ca09330dd33c685eaa69593da78d006518a5
BLAKE2b-256 checksum
How to use checksums
4d49cf2573278ff502985f27812df0d50fe8d61bf5469854c34cbe815e255dd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / discordbook-0.2.4-py3-none-any.whl

Download URL discordbook-0.2.4-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6007b8769d3444f351e73f79f6e50e9b32ca444a0c370c71c2da6eb1c32b1656
BLAKE2b-256 checksum
How to use checksums
e2312d161b7efde9dcd4fce7523f63d3255a94c50891cb5de9ac103bdaeb356f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for discordbook 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page