Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sigmanificient/embed-templator
A Python Template manager for your discord bot to keep your embeds simple consistent
https://github.com/sigmanificient/embed-templator
discord discord-embed discord-embed-builder discordpy pypi pypi-package python python-pakage python3 python38 python39
Last synced: about 2 months ago
JSON representation
A Python Template manager for your discord bot to keep your embeds simple consistent
- Host: GitHub
- URL: https://github.com/sigmanificient/embed-templator
- Owner: Sigmanificient
- License: mit
- Created: 2021-08-23T20:03:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T03:27:55.000Z (9 months ago)
- Last Synced: 2024-04-20T13:56:45.184Z (9 months ago)
- Topics: discord, discord-embed, discord-embed-builder, discordpy, pypi, pypi-package, python, python-pakage, python3, python38, python39
- Language: Python
- Homepage: https://pypi.org/project/embed-templator/
- Size: 132 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Embed Templator
![PyPI - Downloads](https://img.shields.io/pypi/dm/Embed-Templator)
[![PyPI - Downloads](https://img.shields.io/badge/dynamic/json?label=downloads&query=%24.total_downloads&url=https%3A%2F%2Fapi.pepy.tech%2Fapi%2Fprojects%2FEmbed-Templator)](https://pypi.org/project/Embed-Templator/)
![PyPI](https://img.shields.io/pypi/v/Embed-Templator)
![PyPI - Format](https://img.shields.io/pypi/format/Embed-Templator)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Embed-Templator)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Sigmanificient/Embed-Templator)
![GitHub repo size](https://img.shields.io/github/repo-size/Sigmanificient/Embed-Templator)
![GitHub last commit](https://img.shields.io/github/last-commit/Sigmanificient/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:
```bash
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*
```sh
python -m pip install embed-templator
```*python isn't in the path*
```sh
path/to/python.exe -m pip install embed-templator
```*Using multiple python versions*
```sh
py -m pip install embed-templator
```# Usage
### Simplest
The simplest way to use the Embed templator in your project is the following:
```py
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.
```py
from embed_templator import Embedclient = ...
# 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:```py
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:
```py
@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.```py
from __future__ import annotations
import embed_templatorclass 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 !* |
| ------------- | :--------------------------------------------------------- |```py
from __future__ import annotations
import embed_templatorclass 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.