Skip to main content

A small wrapper for easy creation of discord.py Embeds and sending/editing of Messages including those Embeds

Project description

DISCLAIMER!

This package is only vaguely tested.

Installing

Python 3.6 or higher is required

other than that it's just as simple as

pip install discord.py-embed-wrapper
from embed_wrapper import *

Wrapper Classes - Examples/Usage

EmbedField

to create an EmbedField object

wrapped_field = EmbedField(name=field_name, value=field_value, inline=field_inline)

and then use it in the initialisation of an EmbedWrapper

EmbedWrapper

embed_wrapper = EmbedWrapper(
    author_name=author_name, author_url=author_url, author_icon_url=author_icon_url,
    embed_type=embed_type, title=title, url=url, color=color, description=description,
    timestamp=timestamp,
    footer_text=footer_text, footer_icon_url=footer_icon_url,
    image_url=image_url, thumbnail_url=thumbnail_url,
    fields=[wrapped_field]
)

to finalize and instantiate the embed from the wrapper call

embed = embed_wrapper.embed

Helper Functions - Examples/Usage

embeds_from_message

Creates a List of Embeds from a give Message. Returns None if the given Message didn't have any Embeds.

def embeds_from_message(message: Message) -> Optional[List[Embed]]:
    ...

embeds = embeds_from_message(message=message)

send_embed_message

Sends a Message including an Embed to either a Guild TextChannel or a DMChannel and returns the sent Message.

async def send_embed_message(
        embed: Embed,
        invoking_message: Message,
        as_reply: bool = False,
        as_dm: bool = False,
        dm_channel: DMChannel = None,
        pin: bool = False,
        message_content: str = "",
        reactions: List[str] = None,
        mentions: List[Union[User, Member, Role]] = None,
        append_mentions: bool = False
) -> Message:
...

simplest usage

embed_message = await send_embed_message(embed=embed, invoking_message=message)

Sends an Embed Message only containing the embed in the same channel it was invoked.

edit_embed_message

Edits a given Embed Message with a new Embed and optionally new Message Content and returns the edited Message. Pass None as the Embed to remove it.

async def edit_embed_message(
        embed: Embed,
        message: Message,
        message_content: Optional[str],
) -> Message:
...

usage

embed_message = await edit_embed_message(embed=embed, message=embed_message)

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.py-embed-wrapper-0.0.9.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

discord.py_embed_wrapper-0.0.9-py3-none-any.whl (6.4 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