A Python Template manager for your discord bot to keep your embeds simple & consistent.
Project description
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.
:exclamation: | 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.
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
Built Distribution
File details
Details for the file embed-templator-1.0.4.tar.gz
.
File metadata
- Download URL: embed-templator-1.0.4.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ca9d018046c9d0e036de8850fab9edd43b361253ab1382248e3a9bb9fa6bc1c |
|
MD5 | 82ec8bcc360b4934267ab1bd09656177 |
|
BLAKE2b-256 | 9cef8845e429f8d045949ee5d5ab9e5cc342362d7231d5ac3c729c9e8a8df357 |
File details
Details for the file embed_templator-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: embed_templator-1.0.4-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b677e62ef530b4b133016811ae75fa882e0df1da9727a23b765307b64263fb3e |
|
MD5 | 0a774e3bb426c85ff21457f1013991ec |
|
BLAKE2b-256 | 2d34c1602192e90b113c44a2cb67532f2f8349461449cb47cd8b095208ec9e57 |