Embed Templator
Embed Templator
Discord 봇의 Python Template Manager를 간단하고 일관성있게 유지합니다.
다음 명령을 사용하여 Python 환경에 Embed-Templator를 설치하십시오.
pip install Embed-Templator파이썬 설치에 따라 다음 중 하나를 사용해야 할 수도 있습니다.
PIP는 경로에 없지만 Python은입니다
python -m pip install embed-templator파이썬은 경로에 없습니다
path/to/python.exe -m pip install embed-templator여러 파이썬 버전 사용
py -m pip install embed-templator프로젝트에서 Embed Templator를 사용하는 가장 간단한 방법은 다음과 같습니다.
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!' ))그러나 내장 템플레이터는 더 고급 사용을 가질 수 있으며 컨텍스트 임베드를 사용할 수 있습니다.
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!' ))COG 기반 시스템을 사용하는 경우 다음과 같은 톱니에 포함을 시작하는 것을 잊지 마십시오.
class MyBeautifulCog ( commands . Cog ):
def __init__ ( self , client ):
self . client = client
Embed . load ( self . client )그러면 이전 예제처럼 사용할 수 있습니다.
@ commands . command ()
async def my ( self , ctx ):
await ctx . send (
embed = Embed ( ctx )( description = "Cabbage" )
)고급 임베드 구성을 원한다면 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"
)| ❗ | 이 예제는 시간 추적이있는 사용자 정의 CTX를 사용합니다! |
|---|
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 selfembed-templator를 사용해 주셔서 감사합니다!
© 2020 copyright Edhyjox
이 저장소는 MIT 라이센스에 따라 라이센스가 부여됩니다. 자세한 내용은 라이센스를 참조하십시오.