Skip to main content

discord.py advanced embeds

Project description

discord_embed_model

this is an extension of the discord.py library that provides many useful features for creating and modifying embeds

Installation

pip install discord-embed-model

Usage

  1. transforming discord embed into a pydantic instance
from discord import Embed as DiscordEmbed
from discord_embed_model import Embed, to_pydantic_embed

discordEmbed : DiscordEmbed
embed : Embed = to_pydantic_embed(discordEmbed)
  1. formatting embeds using templates
from discord_embed_model import Formatter

template = Formatter(
    title="hello {user.mention}
)

user : discord.User
embed = template.format(user=user) # embed.title == "hello @user"
  1. embed that is retrievable
from discord import Interaction
from discord_embed_model import StatefulEmbed

embed = StatefulEmbed(
    title="i can get this back",
)

embed.cache()

# sent out to discord

interaction : Interaction

# get embed
rembed = interaction.message.embeds[0]

retrieved = StatefulEmbed.retrieve(rembed, target_storage=rembed.TARGET_STORAGE, method=rembed.TARGET_CONTEXT)
assert retrieved is embed

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-embed-model-0.1.3.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

discord_embed_model-0.1.3-py3-none-any.whl (9.3 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