Embed Templator
A Python Template manager for your discord bot to keep your embeds simple & consistent
Installation
Use The following command to install Embed-Templator into your python environment:
pip install Embed-Templator
didn't works?
Depending on your python installation, you might need to use one of the following.
pip isn't in the path but python is
python -m pip install embed-templator
python isn't in the path
path/to/python.exe -m pip install embed-templator
Using multiple python versions
py -m pip install embed-templator
Usage
Simplest
The simplest way to use the Embed templator in your project is the following:
from embed_templator import Embed
# Loading your client instance withing the embed templator.
Embed.load(client)
@client.command()
async def ping(ctx):
# Use it like a regular Embed.
await ctx.send(embed=Embed(description='pong!'))
Context Embeds
However, the embed templator can have more advanced usage, and use context embeds.
from embed_templator import Embed
client = ...
# Note that auto_author requires the ctx to be passed at embeds init.
Embed.load(client, auto_author=True)
@client.command()
async def ping(ctx):
# Use it like a regular Embed.
await ctx.send(embed=Embed(ctx)(description='pong!'))
Cogs
If you are using a cog based system, don't forget to init the embed in your cogs with the following:
class MyBeautifulCog(commands.Cog):
def __init__(self, client):
self.client = client
Embed.load(self.client)
Then you'll be able to use it like the previous examples:
@commands.command()
async def my(self, ctx):
await ctx.send(
embed=Embed(ctx)(description="Cabbage")
)
Advanced Usage
If you want an advanced embed configuration, you can create a custom embed class that will inherit the embed templator.
from __future__ import annotations
import embed_templator
class Embed(embed_templator.Embed):
def setup(self) -> Embed:
return self.set_footer(
text=f"{self.ctx.command} | more info @ {self.ctx.prefix}help"
)
You can also use the `update` method for last changes in the embed, better it will be sent.
| ❗ | This example uses a custom ctx that have time tracking ! |
|---|
from __future__ import annotations
import embed_templator
class Embed(embed_templator.Embed):
def setup(self) -> Embed:
return self.set_author(
name=f"Requested by {self.ctx.author} 🚀",
icon_url=self.ctx.author.avatar_url
)
def update(self) -> Embed:
self.set_footer(
icon_url=self.client.user.avatar_url,
text=' '.join(
(
f"⚙️ {self.ctx.time.elapsed()}",
f"⏳ {self.client.latency}",
f"🔑 {self.ctx.prefix}help",
)
)
)
return self
Thanks for using Embed-Templator!
License
© 2020 copyright Edhyjox
This repository is licensed under the MIT License. See LICENSE for details.
Metadata
Release files for embed-templator 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| embed-templator-1.0.4.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| embed_templator-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.0 kB
Release files / embed-templator-1.0.4.tar.gz
| Download URL | embed-templator-1.0.4.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ca9d018046c9d0e036de8850fab9edd43b361253ab1382248e3a9bb9fa6bc1c
|
|
BLAKE2b-256 checksum How to use checksums |
9cef8845e429f8d045949ee5d5ab9e5cc342362d7231d5ac3c729c9e8a8df357
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|
Release files / embed_templator-1.0.4-py3-none-any.whl
| Download URL | embed_templator-1.0.4-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b677e62ef530b4b133016811ae75fa882e0df1da9727a23b765307b64263fb3e
|
|
BLAKE2b-256 checksum How to use checksums |
2d34c1602192e90b113c44a2cb67532f2f8349461449cb47cd8b095208ec9e57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|