General tools¶
Collection of uncategorized tools
- class dpytools.__init__.Color(value)¶
Enum class with nice color values that can be used directly on embeds
Example:
from dpytools import Color embed = discord.Embed(description="embed example", color=Color.FIRE_ORANGE)
Note
- Available colors:
CYAN = 0x00FFFF GOLD = 0xFFD700 YELLOW = 0xffff00 RED = 0xFF0000 LIME = 0x00FF00 VIOLET = 0xEE82EE PINK = 0xFFC0CB FUCHSIA = 0xFF00FF BLUE = 0x0000FF PURPLE = 0x8A2BE2 FIRE_ORANGE = 0xFF4500 COSMIC_LATTE = 0xFFF8E7 BABY_BLUE = 0x89cff0
- class dpytools.__init__.Embed(**kwargs)¶
This is a subclass of
discord.Embed
which accepts its default values plus image and thumbnail in the constructor and adds an additional method add_fields- Parameters
title – The title of the embed.
type – The type of embed. Usually “rich”. Official documentation states this is soon to be deprecated.
description – The description of the embed.
url – The URL of the embed.
timestamp – The timestamp of the embed content. This could be a naive or aware datetime.
(or color) (colour) – The colour code of the embed.
image – The image url. Calls the internal “set_image” method with the kwarg value as the url.
thumbnail – The thumbnail url. Calls the internal “set_thumbnail” method with the kwarg value as the url.
author – A dict containing (optional) “name”, “url”, and “icon_url” fields. Calls the internal “set_author” method, setting the author name, url, and icon_url if applicable.
footer – A dict containing (optional) “text” and “icon_url” fields. Calls the internal “set_footer” method, setting the footer text and icon_url if applicable.
- add_fields(inline=True, **kwargs) → discord.embeds.Embed¶
Works in a similar way to Embed.add_field but you can add as many fields as you need by passing them as kwargs in the constructor.
- Parameters
inline (
bool
) – if the fields will be inline or notkwargs – key/value pairs for each field’s name and value respectively
Example:
from dpytools import Embed embed = Embed() embed.add_fields(inline=False, first="this is the first field's value", second="Second field value")
Note
If you need to add a sentence in the field’s name just construct a dictionary and pass it with **.
Example:
embed.add_fields(**{'first field': 'first field value'})
- property is_valid¶
Returns a bool for whether the length of the embed is valid
- class dpytools.__init__.Emoji(value)¶
Enum class with common emojis used for reaction messages or related interactions
Example:
from dpytools import Emoji message.add_reaction(Emoji.SMILE)
Note
- Included Emojis:
SMILE = 🙂, THUMBS_UP = 👍, THUMBS_DOWN = 👎,
HEART = ❤️,GREEN_CHECK = ✅, X = ❌,
PROHIBITED = 🚫, FIRE = 🔥, STAR = ⭐,
RED_CIRCLE = 🔴, GREEN_CIRCLE = 🟢, YELLOW_CIRCLE = 🟡,
LAST_TRACK = ⏮️, REVERSE = ◀️, PLAY = ▶️,
NEXT_TRACK = ⏭️, PAUSE = ⏸️, FIRST_PLACE_MEDAL = 🥇,
SECOND_PLACE_MEDAL = 🥈, THIRD_PLACE_MEDAL = 🥉,
ONE = 1️⃣, TWO = 2️⃣, THREE = 3️⃣,
FOUR = 4️⃣, FIVE = 5️⃣, SIX = 6️⃣,
SEVEN = 7️⃣, EIGHT = 8️⃣, NINE = 9️⃣,
TEN = 🔟, ZERO = 0️⃣
- class dpytools.__init__.EmojiNumbers(value)¶
Shortcut enum class that contains the number emojis from
Emoji
- for ... in dpytools.__init__.chunkify(input_list: List[Any], max_number: int) → List[List[Any]]¶
Splits a list into :n: sized chunks
- Parameters
input_list (
List[Any]
) – The list to make chunks frommax_number (
int
) – The maximum amount of items per chunk
- Yields
Chunks of size equal or lower to *max_number*
- for ... in dpytools.__init__.chunkify_string_list(input_list: List[str], max_number: int, max_length: int, separator_length: int = 0) → List[List[str]]¶
Splits a list of strings into :param max_number: sized chunks or sized at maximum joint length of :param max_length:
- Parameters
input_list (
List[str]
) – A list of stringsmax_number (
int
) – Maximum amount of items per chunkmax_length (
int
) – Maximum amount of characters per chunkseparator_length (
int
) – If the strings will be eventually joined together, the :param separator_length: is considered into :param max_length:
- Yields
List[List[str]]