embed-model 0.3__py3-none-any.whl → 0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- embed_model/__init__.py +74 -5
- embed_model/menus.py +3 -16
- {embed_model-0.3.dist-info → embed_model-0.4.dist-info}/METADATA +1 -1
- {embed_model-0.3.dist-info → embed_model-0.4.dist-info}/RECORD +6 -6
- {embed_model-0.3.dist-info → embed_model-0.4.dist-info}/WHEEL +0 -0
- {embed_model-0.3.dist-info → embed_model-0.4.dist-info}/top_level.txt +0 -0
embed_model/__init__.py
CHANGED
@@ -1,14 +1,28 @@
|
|
1
1
|
import discord
|
2
2
|
from discord import app_commands
|
3
3
|
import json
|
4
|
-
from .menus import EmbedGenerator
|
5
4
|
|
6
|
-
class
|
5
|
+
class EmbedGenerator(discord.ui.View):
|
6
|
+
def __init__(self, msg: discord.Message):
|
7
|
+
from .menus import EditarFieldMenus, RemoverFieldMenus, LinguagemSelect
|
8
|
+
from .buttons import EditButton, FooterButton, AddFieldButton, SendButton
|
9
|
+
super().__init__(timeout=None)
|
10
|
+
self.add_item(EditButton(msg, 0))
|
11
|
+
self.add_item(EditButton(msg, 1))
|
12
|
+
self.add_item(FooterButton(msg))
|
13
|
+
self.add_item(AddFieldButton(msg))
|
14
|
+
self.add_item(SendButton(msg))
|
15
|
+
if msg.embeds[0].fields:
|
16
|
+
self.add_item(RemoverFieldMenus(msg))
|
17
|
+
self.add_item(EditarFieldMenus(msg))
|
18
|
+
self.add_item(LinguagemSelect())
|
19
|
+
|
20
|
+
class EmbedModelCommands(app_commands.Group):
|
7
21
|
def __init__(self, bot: discord.Client):
|
8
|
-
super().__init__()
|
22
|
+
super().__init__(name="embed", description="Comandos padrões de embeds.")
|
9
23
|
self.bot = bot
|
10
24
|
|
11
|
-
@app_commands.command(name="
|
25
|
+
@app_commands.command(name="create", description="Cria um embed")
|
12
26
|
@app_commands.checks.has_permissions(manage_webhooks=True)
|
13
27
|
@app_commands.describe(
|
14
28
|
template="Um template do embed que será editado"
|
@@ -79,4 +93,59 @@ class EmbedModelCommands(app_commands.AppCommandGroup):
|
|
79
93
|
await interaction.response.defer(ephemeral=True)
|
80
94
|
await interaction.followup.send(content=content, embed=embed, ephemeral=True)
|
81
95
|
msg = await interaction.original_response()
|
82
|
-
await msg.edit(view=EmbedGenerator(msg))
|
96
|
+
await msg.edit(view=EmbedGenerator(msg))
|
97
|
+
|
98
|
+
@app_commands.command(name="json", description="Ajuda com o modelo JSON dos embeds")
|
99
|
+
async def json_help(self, interaction: discord.Interaction):
|
100
|
+
embed = discord.Embed(
|
101
|
+
title="📖 Como usar os modelos JSON de embeds",
|
102
|
+
description="Aqui está um exemplo de como montar um template JSON para o comando `/embed create`:",
|
103
|
+
colour=discord.Color.blurple()
|
104
|
+
)
|
105
|
+
|
106
|
+
exemplo_json = """```json
|
107
|
+
{
|
108
|
+
"title": "Título do Embed",
|
109
|
+
"description": "Descrição do Embed",
|
110
|
+
"color": "#5865F2",
|
111
|
+
"content": "Mensagem fora do embed",
|
112
|
+
"author": {
|
113
|
+
"name": "Autor",
|
114
|
+
"url": "https://example.com",
|
115
|
+
"icon_url": "https://link-da-imagem.com/icon.png"
|
116
|
+
},
|
117
|
+
"thumbnail": {
|
118
|
+
"url": "https://link-da-imagem.com/thumb.png"
|
119
|
+
},
|
120
|
+
"image": {
|
121
|
+
"url": "https://link-da-imagem.com/image.png"
|
122
|
+
},
|
123
|
+
"footer": {
|
124
|
+
"text": "Rodapé",
|
125
|
+
"icon_url": "https://link-da-imagem.com/footer.png"
|
126
|
+
},
|
127
|
+
"fields": [
|
128
|
+
{
|
129
|
+
"name": "Campo 1",
|
130
|
+
"value": "Valor do campo 1",
|
131
|
+
"inline": true
|
132
|
+
},
|
133
|
+
{
|
134
|
+
"name": "Campo 2",
|
135
|
+
"value": "Valor do campo 2",
|
136
|
+
"inline": false
|
137
|
+
}
|
138
|
+
]
|
139
|
+
}
|
140
|
+
```"""
|
141
|
+
|
142
|
+
embed.add_field(name="📝 Exemplo de JSON", value=exemplo_json, inline=False)
|
143
|
+
embed.add_field(
|
144
|
+
name="ℹ️ Observações",
|
145
|
+
value="• Os campos `author`, `thumbnail`, `image`, `footer` e `fields` são opcionais.\n"
|
146
|
+
"• A cor deve estar em formato hexadecimal (`#RRGGBB`).\n"
|
147
|
+
"• Você também pode usar o link de uma mensagem como template no comando `/embed create`.",
|
148
|
+
inline=False
|
149
|
+
)
|
150
|
+
|
151
|
+
await interaction.response.send_message(embed=embed, ephemeral=True)
|
embed_model/menus.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import discord
|
2
|
-
from .
|
2
|
+
from . import EmbedGenerator
|
3
3
|
from .modals import EditFieldModal
|
4
4
|
|
5
5
|
class RemoverFieldMenus(discord.ui.Select):
|
@@ -117,7 +117,7 @@ class LinguagemSelect(discord.ui.Select):
|
|
117
117
|
js_code = "const embed = {\n"
|
118
118
|
js_code += f' title: "{embed.title}",\n'
|
119
119
|
js_code += f' description: "{descricao}",\n'
|
120
|
-
js_code += f' color: {embed.colour.value if embed.colour else
|
120
|
+
js_code += f' color: {'"#{:06X}"'.format(embed.colour.value) if embed.colour else 'null'},\n'
|
121
121
|
js_code += f' timestamp: "{embed.timestamp.isoformat()}"' if embed.timestamp else ""
|
122
122
|
if embed.author:
|
123
123
|
js_code += f',\n author: {{\n name: "{embed.author.name}"'
|
@@ -151,17 +151,4 @@ class LinguagemSelect(discord.ui.Select):
|
|
151
151
|
code = f"```javascript\n{js_code}```"
|
152
152
|
|
153
153
|
# Responder com o código correspondente
|
154
|
-
await interaction.response.send_message(code, ephemeral=True)
|
155
|
-
|
156
|
-
class EmbedGenerator(discord.ui.View):
|
157
|
-
def __init__(self, msg: discord.Message):
|
158
|
-
super().__init__(timeout=None)
|
159
|
-
self.add_item(EditButton(msg, 0))
|
160
|
-
self.add_item(EditButton(msg, 1))
|
161
|
-
self.add_item(FooterButton(msg))
|
162
|
-
self.add_item(AddFieldButton(msg))
|
163
|
-
self.add_item(SendButton(msg))
|
164
|
-
if msg.embeds[0].fields:
|
165
|
-
self.add_item(RemoverFieldMenus(msg))
|
166
|
-
self.add_item(EditarFieldMenus(msg))
|
167
|
-
self.add_item(LinguagemSelect())
|
154
|
+
await interaction.response.send_message(code, ephemeral=True)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
embed-model/__init__.py,sha256=GPy9PjPYdp9Bkk2q7-Ax6OWN6vvVf2gMN0qwKuSWczE,20
|
2
2
|
embed-model/modulo.py,sha256=Z3_Is6T3PxU5QXO4i7t-L40MlDlcAqS3Eti77yxADFo,18431
|
3
|
-
embed_model/__init__.py,sha256=
|
3
|
+
embed_model/__init__.py,sha256=T8NZU1xAlXNJ47quC8Yu4LbU_OWH7TrnITp_VhnziUA,5592
|
4
4
|
embed_model/buttons.py,sha256=ejaS65Ww5x4DZI06r0uqh6rdkzNVXP7jxPgrMc4V32Y,2033
|
5
|
-
embed_model/menus.py,sha256=
|
5
|
+
embed_model/menus.py,sha256=3g1Q_n4TP_91kqH6poehq92avuRBf7hO4GZ9QcmJdiY,6320
|
6
6
|
embed_model/modals.py,sha256=ZfOOeeodmlYUIgRoi--mYhSPu20y_7Pk4zfSQeWJGrA,6970
|
7
7
|
embed_model/modulo.py,sha256=Z3_Is6T3PxU5QXO4i7t-L40MlDlcAqS3Eti77yxADFo,18431
|
8
|
-
embed_model-0.
|
9
|
-
embed_model-0.
|
10
|
-
embed_model-0.
|
11
|
-
embed_model-0.
|
8
|
+
embed_model-0.4.dist-info/METADATA,sha256=lrujdR-zm5s5PplbozYhmO5nzy4yO_M6HkVJ4Mv6vAw,1832
|
9
|
+
embed_model-0.4.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
10
|
+
embed_model-0.4.dist-info/top_level.txt,sha256=de9m0qp01SqUQYtnlOoOOlGtfgttPyh38cxJqGjtSLs,12
|
11
|
+
embed_model-0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|