embed-model 0.1__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
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
from . import modulo
|
embed-model/modulo.py
ADDED
@@ -0,0 +1,443 @@
|
|
1
|
+
import discord
|
2
|
+
import json
|
3
|
+
from discord import app_commands
|
4
|
+
|
5
|
+
class EmbedTextModal(discord.ui.Modal, title="Editar Embed (Textos)"):
|
6
|
+
def __init__(self, message: discord.Message):
|
7
|
+
super().__init__()
|
8
|
+
self.message = message
|
9
|
+
self.embed = message.embeds[0]
|
10
|
+
|
11
|
+
self.msg_content.default = message.content
|
12
|
+
self.embed_title.default = self.embed.title
|
13
|
+
self.embed_description.default = self.embed.description
|
14
|
+
self.embed_color.default = f"#{self.embed.colour.value:06x}" if self.embed.colour else "#FFFFFF"
|
15
|
+
|
16
|
+
msg_content = discord.ui.TextInput(label="Conteúdo", style=discord.TextStyle.short, required=False)
|
17
|
+
embed_title = discord.ui.TextInput(label="Embed Title", style=discord.TextStyle.short)
|
18
|
+
embed_description = discord.ui.TextInput(label="Embed Description", style=discord.TextStyle.long)
|
19
|
+
embed_color = discord.ui.TextInput(label="Embed Color (e.g., #FFFFFF)", style=discord.TextStyle.short, required=False)
|
20
|
+
|
21
|
+
async def on_submit(self, interaction: discord.Interaction):
|
22
|
+
try:
|
23
|
+
embed = self.message.embeds[0]
|
24
|
+
embed.title = self.embed_title.value
|
25
|
+
embed.description = self.embed_description.value
|
26
|
+
|
27
|
+
if self.embed_color.value:
|
28
|
+
embed.colour = discord.Color.from_str(self.embed_color.value)
|
29
|
+
|
30
|
+
self.message = await self.message.edit(content=self.msg_content.value, embed=embed, view=EmbedGenerator(self.message))
|
31
|
+
await self.message.edit(content=self.msg_content.value, embed=embed, view=EmbedGenerator(self.message))
|
32
|
+
await interaction.response.send_message("Texto do Embed atualizado com sucesso!", ephemeral=True)
|
33
|
+
except ValueError:
|
34
|
+
await interaction.response.send_message(
|
35
|
+
content="A cor fornecida é inválida! Use um formato como `#RRGGBB`.",
|
36
|
+
ephemeral=True,
|
37
|
+
)
|
38
|
+
|
39
|
+
class EmbedImageModal(discord.ui.Modal, title="Editar Embed (Imagens e Timestamp)"):
|
40
|
+
def __init__(self, message: discord.Message):
|
41
|
+
super().__init__()
|
42
|
+
self.message = message
|
43
|
+
self.embed = message.embeds[0]
|
44
|
+
|
45
|
+
self.embed_thumbnail.default = self.embed.thumbnail.url if self.embed.thumbnail else ""
|
46
|
+
self.embed_image.default = self.embed.image.url if self.embed.image else ""
|
47
|
+
self.embed_timestamp.default = "True" if self.embed.timestamp else "False"
|
48
|
+
|
49
|
+
embed_thumbnail = discord.ui.TextInput(label="Thumbnail URL", style=discord.TextStyle.short, required=False)
|
50
|
+
embed_image = discord.ui.TextInput(label="Imagem URL", style=discord.TextStyle.short, required=False)
|
51
|
+
embed_timestamp = discord.ui.TextInput(label="Timestamp (True/False)", style=discord.TextStyle.short)
|
52
|
+
|
53
|
+
async def on_submit(self, interaction: discord.Interaction):
|
54
|
+
embed = self.message.embeds[0]
|
55
|
+
|
56
|
+
# Verifica se uma thumbnail foi fornecida e adiciona
|
57
|
+
if self.embed_thumbnail.value:
|
58
|
+
embed.set_thumbnail(url=self.embed_thumbnail.value)
|
59
|
+
|
60
|
+
# Verifica se uma imagem foi fornecida e adiciona
|
61
|
+
if self.embed_image.value:
|
62
|
+
embed.set_image(url=self.embed_image.value)
|
63
|
+
|
64
|
+
# Verifica o valor de timestamp
|
65
|
+
if self.embed_timestamp.value.lower() == "true":
|
66
|
+
embed.timestamp = discord.utils.utcnow()
|
67
|
+
elif self.embed_timestamp.value.lower() == "false":
|
68
|
+
embed.timestamp = None
|
69
|
+
|
70
|
+
await self.message.edit(embed=embed, view=EmbedGenerator(self.message))
|
71
|
+
await interaction.response.send_message("Imagem e Timestamp do Embed atualizados com sucesso!", ephemeral=True)
|
72
|
+
|
73
|
+
class EditButton(discord.ui.Button):
|
74
|
+
def __init__(self, message: discord.Message, tipo: int):
|
75
|
+
tipos = ["textos", "imagens"]
|
76
|
+
self.tipo = tipo
|
77
|
+
super().__init__(label="Editar " + tipos[tipo], style=discord.ButtonStyle.blurple, emoji="📝")
|
78
|
+
self.message = message
|
79
|
+
|
80
|
+
async def callback(self, interaction: discord.Interaction):
|
81
|
+
if self.tipo == 0:
|
82
|
+
modal = EmbedTextModal(message=self.message)
|
83
|
+
else:
|
84
|
+
modal = EmbedImageModal(message=self.message)
|
85
|
+
await interaction.response.send_modal(modal)
|
86
|
+
|
87
|
+
class FooterModal(discord.ui.Modal, title="Editar Footer do Embed"):
|
88
|
+
def __init__(self, message: discord.Message):
|
89
|
+
super().__init__()
|
90
|
+
self.message = message
|
91
|
+
self.embed = message.embeds[0]
|
92
|
+
self.embed_footer_text.default = self.embed.footer.text if self.embed.footer else ""
|
93
|
+
self.embed_footer_image.default = self.embed.footer.icon_url if self.embed.footer and self.embed.footer.icon_url else ""
|
94
|
+
|
95
|
+
embed_footer_text = discord.ui.TextInput(label="Footer Text", style=discord.TextStyle.short, required=False)
|
96
|
+
embed_footer_image = discord.ui.TextInput(label="Footer Image URL", style=discord.TextStyle.short, required=False)
|
97
|
+
|
98
|
+
async def on_submit(self, interaction: discord.Interaction):
|
99
|
+
try:
|
100
|
+
embed = self.message.embeds[0]
|
101
|
+
footer_text = self.embed_footer_text.value
|
102
|
+
footer_image_url = self.embed_footer_image.value
|
103
|
+
|
104
|
+
# Se o texto e a imagem forem fornecidos, define ambos
|
105
|
+
if footer_text and footer_image_url:
|
106
|
+
embed.set_footer(text=footer_text, icon_url=footer_image_url)
|
107
|
+
elif footer_text:
|
108
|
+
embed.set_footer(text=footer_text)
|
109
|
+
elif footer_image_url:
|
110
|
+
embed.set_footer(icon_url=footer_image_url)
|
111
|
+
|
112
|
+
await self.message.edit(embed=embed)
|
113
|
+
await interaction.response.send_message("Footer atualizado com sucesso!", ephemeral=True)
|
114
|
+
except Exception as e:
|
115
|
+
await interaction.response.send_message(
|
116
|
+
content=f"Ocorreu um erro ao tentar atualizar o footer: {str(e)}",
|
117
|
+
ephemeral=True,
|
118
|
+
)
|
119
|
+
|
120
|
+
class FooterButton(discord.ui.Button):
|
121
|
+
def __init__(self, message: discord.Message):
|
122
|
+
super().__init__(label="Footer", style=discord.ButtonStyle.blurple, emoji="🦶")
|
123
|
+
self.message = message
|
124
|
+
|
125
|
+
async def callback(self, interaction: discord.Interaction):
|
126
|
+
modal = FooterModal(message=self.message)
|
127
|
+
await interaction.response.send_modal(modal)
|
128
|
+
|
129
|
+
class FieldModal(discord.ui.Modal, title="Adicionar Field"):
|
130
|
+
field_name = discord.ui.TextInput(label="Field Name", style=discord.TextStyle.short)
|
131
|
+
field_value = discord.ui.TextInput(label="Field Value", style=discord.TextStyle.long)
|
132
|
+
field_inline = discord.ui.TextInput(label="Inline (True/False)", style=discord.TextStyle.short)
|
133
|
+
|
134
|
+
def __init__(self, message: discord.Message):
|
135
|
+
super().__init__()
|
136
|
+
self.message = message
|
137
|
+
|
138
|
+
async def on_submit(self, interaction: discord.Interaction):
|
139
|
+
try:
|
140
|
+
inline = self.field_inline.value.lower() == "true"
|
141
|
+
|
142
|
+
embed = self.message.embeds[0]
|
143
|
+
embed.add_field(name=self.field_name.value, value=self.field_value.value, inline=inline)
|
144
|
+
|
145
|
+
await self.message.edit(embed=embed, view=EmbedGenerator(self.message))
|
146
|
+
await interaction.response.send_message("Field adicionado com sucesso!", ephemeral=True)
|
147
|
+
except IndexError:
|
148
|
+
await interaction.response.send_message(
|
149
|
+
content="Erro: Nenhum embed foi encontrado na mensagem!",
|
150
|
+
ephemeral=True,
|
151
|
+
)
|
152
|
+
|
153
|
+
class SendButton(discord.ui.Button):
|
154
|
+
def __init__(self, msg: discord.Message):
|
155
|
+
super().__init__(label="Enviar", style=discord.ButtonStyle.green, emoji="✅")
|
156
|
+
self.msg = msg
|
157
|
+
|
158
|
+
async def callback(self, interaction: discord.Interaction):
|
159
|
+
await self.msg.channel.send(content=self.msg.content, embed=self.msg.embeds[0])
|
160
|
+
await interaction.response.send_message("Embed enviado com sucesso!", ephemeral=True)
|
161
|
+
|
162
|
+
class CancelButton(discord.ui.Button):
|
163
|
+
def __init__(self, msg: discord.Message):
|
164
|
+
super().__init__(label="Cancelar", style=discord.ButtonStyle.red, emoji="❌")
|
165
|
+
self.msg = msg
|
166
|
+
|
167
|
+
async def callback(self, interaction: discord.Interaction):
|
168
|
+
await self.msg.delete()
|
169
|
+
|
170
|
+
class AddFieldButton(discord.ui.Button):
|
171
|
+
def __init__(self, message: discord.Message):
|
172
|
+
super().__init__(label="Adicionar Field", style=discord.ButtonStyle.gray, emoji="➕")
|
173
|
+
self.message = message
|
174
|
+
|
175
|
+
async def callback(self, interaction: discord.Interaction):
|
176
|
+
modal = FieldModal(message=self.message)
|
177
|
+
await interaction.response.send_modal(modal)
|
178
|
+
|
179
|
+
class RemoverFieldMenus(discord.ui.Select):
|
180
|
+
def __init__(self, message: discord.Message):
|
181
|
+
if not message.embeds or not message.embeds[0].fields:
|
182
|
+
raise ValueError("A mensagem não contém embeds ou campos para remover.")
|
183
|
+
|
184
|
+
embed = message.embeds[0]
|
185
|
+
fields = embed.fields
|
186
|
+
|
187
|
+
options = [
|
188
|
+
discord.SelectOption(label=field.name, value=str(i)) for i, field in enumerate(fields)
|
189
|
+
]
|
190
|
+
|
191
|
+
super().__init__(placeholder="Selecione um Field para remover", options=options)
|
192
|
+
|
193
|
+
self.message = message
|
194
|
+
|
195
|
+
async def callback(self, interaction: discord.Interaction):
|
196
|
+
field_index = int(self.values[0])
|
197
|
+
embed = self.message.embeds[0]
|
198
|
+
|
199
|
+
embed.remove_field(field_index)
|
200
|
+
|
201
|
+
await self.message.edit(embed=embed, view=EmbedGenerator(self.message))
|
202
|
+
|
203
|
+
class EditarFieldMenus(discord.ui.Select):
|
204
|
+
def __init__(self, message: discord.Message):
|
205
|
+
if not message.embeds or not message.embeds[0].fields:
|
206
|
+
raise ValueError("A mensagem não contém embeds ou campos para editar.")
|
207
|
+
|
208
|
+
embed = message.embeds[0]
|
209
|
+
fields = embed.fields
|
210
|
+
|
211
|
+
options = [
|
212
|
+
discord.SelectOption(label=field.name, value=str(i)) for i, field in enumerate(fields)
|
213
|
+
]
|
214
|
+
|
215
|
+
super().__init__(placeholder="Selecione um Field para editar", options=options)
|
216
|
+
|
217
|
+
self.message = message
|
218
|
+
|
219
|
+
async def callback(self, interaction: discord.Interaction):
|
220
|
+
field_index = int(self.values[0])
|
221
|
+
embed = self.message.embeds[0]
|
222
|
+
field = embed.fields[field_index]
|
223
|
+
|
224
|
+
modal = EditFieldModal(self.message, field_index, field.name, field.value, str(field.inline))
|
225
|
+
await interaction.response.send_modal(modal)
|
226
|
+
|
227
|
+
class EditFieldModal(discord.ui.Modal, title="Editar Field"):
|
228
|
+
def __init__(self, message: discord.Message, field_index: int, field_name: str, field_value: str, field_inline: str):
|
229
|
+
super().__init__()
|
230
|
+
|
231
|
+
self.message = message
|
232
|
+
self.field_index = field_index
|
233
|
+
|
234
|
+
self.field_name = discord.ui.TextInput(label="Nome do Field", default=field_name)
|
235
|
+
self.field_value = discord.ui.TextInput(label="Valor do Field", default=field_value, style=discord.TextStyle.paragraph)
|
236
|
+
|
237
|
+
self.field_inline = discord.ui.TextInput(label="Inline do Field", default=field_inline, style=discord.TextStyle.paragraph)
|
238
|
+
|
239
|
+
self.add_item(self.field_name)
|
240
|
+
self.add_item(self.field_value)
|
241
|
+
self.add_item(self.field_inline)
|
242
|
+
|
243
|
+
async def on_submit(self, interaction: discord.Interaction):
|
244
|
+
embed = self.message.embeds[0]
|
245
|
+
inline = True if self.field_inline.value.lower() == "True" else False
|
246
|
+
embed.set_field_at(self.field_index, name=self.field_name.value, value=self.field_value.value, inline=inline)
|
247
|
+
|
248
|
+
await self.message.edit(embed=embed, view=EmbedGenerator(self.message))
|
249
|
+
await interaction.response.send_message("Field atualizado com sucesso!", ephemeral=True)
|
250
|
+
|
251
|
+
class LinguagemSelect(discord.ui.Select):
|
252
|
+
def __init__(self):
|
253
|
+
options = [
|
254
|
+
discord.SelectOption(label="Python", description="Gerar código em Python", emoji="🐍"),
|
255
|
+
discord.SelectOption(label="JSON", description="Gerar código em JSON", emoji="📄"),
|
256
|
+
discord.SelectOption(label="JavaScript", description="Gerar código em JavaScript", emoji="🛠️"),
|
257
|
+
]
|
258
|
+
super().__init__(placeholder="Escolha uma linguagem", options=options)
|
259
|
+
|
260
|
+
async def callback(self, interaction: discord.Interaction):
|
261
|
+
embed = interaction.message.embeds[0]
|
262
|
+
|
263
|
+
descricao = embed.description.replace('\n', '\\n')
|
264
|
+
python_code = f"discord.Embed(title=\"{embed.title}\", description=\"{descricao}\", timestamp={embed.timestamp}"
|
265
|
+
python_code += f", colour=discord.Color.from_str({'"#{:06X}"'.format(embed.colour)}))" if embed.colour else ")"
|
266
|
+
if embed.author:
|
267
|
+
python_code += f"\nembed.set_author(name=\"{embed.author.name}\""
|
268
|
+
if embed.author.url:
|
269
|
+
python_code += f", url=\"{embed.author.url}\""
|
270
|
+
if embed.author.icon_url:
|
271
|
+
python_code += f", icon_url=\"{embed.author.icon_url}\""
|
272
|
+
python_code += ")"
|
273
|
+
if embed.image:
|
274
|
+
python_code += f"\nembed.set_image(url=\"{embed.image.url}\")"
|
275
|
+
if embed.thumbnail:
|
276
|
+
python_code += f"\nembed.set_thumbnail(url=\"{embed.thumbnail.url}\")"
|
277
|
+
if embed.footer:
|
278
|
+
python_code += f"\nembed.set_footer(text=\"{embed.footer.text}\""
|
279
|
+
if embed.footer.icon_url:
|
280
|
+
python_code += f", icon_url=\"{embed.footer.icon_url}\""
|
281
|
+
python_code += ")"
|
282
|
+
for field in embed.fields:
|
283
|
+
python_code += f"\nembed.add_field(name=\"{field.name}\", value=\"{field.value}\", inline={field.inline})"
|
284
|
+
|
285
|
+
# Gerar código em JSON
|
286
|
+
json_code = "{\n"
|
287
|
+
json_code += f' "title": "{embed.title}",\n'
|
288
|
+
json_code += f' "description": "{descricao}",\n'
|
289
|
+
json_code += f' "color": {'"#{:06X}"'.format(embed.colour.value) if embed.colour else None},\n'
|
290
|
+
json_code += f' "timestamp": "{embed.timestamp.isoformat()}"' if embed.timestamp else ""
|
291
|
+
if embed.author:
|
292
|
+
json_code += f',\n "author": {{\n "name": "{embed.author.name}"'
|
293
|
+
if embed.author.url:
|
294
|
+
json_code += f',\n "url": "{embed.author.url}"'
|
295
|
+
if embed.author.icon_url:
|
296
|
+
json_code += f',\n "icon_url": "{embed.author.icon_url}"'
|
297
|
+
json_code += "\n }"
|
298
|
+
if embed.image:
|
299
|
+
json_code += f',\n "image": {{\n "url": "{embed.image.url}"\n }}'
|
300
|
+
if embed.thumbnail:
|
301
|
+
json_code += f',\n "thumbnail": {{\n "url": "{embed.thumbnail.url}"\n }}'
|
302
|
+
if embed.footer:
|
303
|
+
json_code += f',\n "footer": {{\n "text": "{embed.footer.text}"'
|
304
|
+
if embed.footer.icon_url:
|
305
|
+
json_code += f',\n "icon_url": "{embed.footer.icon_url}"'
|
306
|
+
json_code += "\n }"
|
307
|
+
if embed.fields:
|
308
|
+
json_code += ',\n "fields": ['
|
309
|
+
for field in embed.fields:
|
310
|
+
json_code += f'\n {{\n "name": "{field.name}",\n "value": "{field.value}",\n "inline": "{str(field.inline).lower()}"\n }},'
|
311
|
+
json_code = json_code.rstrip(",") + "\n ]"
|
312
|
+
json_code += "\n}"
|
313
|
+
|
314
|
+
# Gerar código em JavaScript
|
315
|
+
js_code = "const embed = {\n"
|
316
|
+
js_code += f' title: "{embed.title}",\n'
|
317
|
+
js_code += f' description: "{descricao}",\n'
|
318
|
+
js_code += f' color: {embed.colour.value if embed.colour else "null"},\n'
|
319
|
+
js_code += f' timestamp: "{embed.timestamp.isoformat()}"' if embed.timestamp else ""
|
320
|
+
if embed.author:
|
321
|
+
js_code += f',\n author: {{\n name: "{embed.author.name}"'
|
322
|
+
if embed.author.url:
|
323
|
+
js_code += f',\n url: "{embed.author.url}"'
|
324
|
+
if embed.author.icon_url:
|
325
|
+
js_code += f',\n icon_url: "{embed.author.icon_url}"'
|
326
|
+
js_code += "\n }"
|
327
|
+
if embed.image:
|
328
|
+
js_code += f',\n image: {{\n url: "{embed.image.url}"\n }}'
|
329
|
+
if embed.thumbnail:
|
330
|
+
js_code += f',\n thumbnail: {{\n url: "{embed.thumbnail.url}"\n }}'
|
331
|
+
if embed.footer:
|
332
|
+
js_code += f',\n footer: {{\n text: "{embed.footer.text}"'
|
333
|
+
if embed.footer.icon_url:
|
334
|
+
js_code += f',\n icon_url: "{embed.footer.icon_url}"'
|
335
|
+
js_code += "\n }"
|
336
|
+
if embed.fields:
|
337
|
+
js_code += ',\n fields: ['
|
338
|
+
for field in embed.fields:
|
339
|
+
js_code += f'\n {{\n name: "{field.name}",\n value: "{field.value}",\n inline: {str(field.inline).lower()}\n }},'
|
340
|
+
js_code = js_code.rstrip(",") + "\n ]"
|
341
|
+
js_code += "\n};"
|
342
|
+
|
343
|
+
# Determinar o código com base na linguagem selecionada
|
344
|
+
if self.values[0] == "Python":
|
345
|
+
code = f"```python\n{python_code}```"
|
346
|
+
elif self.values[0] == "JSON":
|
347
|
+
code = f"```json\n{json_code}```"
|
348
|
+
elif self.values[0] == "JavaScript":
|
349
|
+
code = f"```javascript\n{js_code}```"
|
350
|
+
|
351
|
+
# Responder com o código correspondente
|
352
|
+
await interaction.response.send_message(code, ephemeral=True)
|
353
|
+
|
354
|
+
class EmbedGenerator(discord.ui.View):
|
355
|
+
def __init__(self, msg: discord.Message):
|
356
|
+
super().__init__(timeout=None)
|
357
|
+
self.add_item(EditButton(msg, 0))
|
358
|
+
self.add_item(EditButton(msg, 1))
|
359
|
+
self.add_item(FooterButton(msg))
|
360
|
+
self.add_item(AddFieldButton(msg))
|
361
|
+
self.add_item(SendButton(msg))
|
362
|
+
if msg.embeds[0].fields:
|
363
|
+
self.add_item(RemoverFieldMenus(msg))
|
364
|
+
self.add_item(EditarFieldMenus(msg))
|
365
|
+
self.add_item(LinguagemSelect())
|
366
|
+
|
367
|
+
class EmbedModelCommands(app_commands.AppCommandGroup):
|
368
|
+
def __init__(self, bot: discord.Client):
|
369
|
+
super().__init__()
|
370
|
+
self.bot = bot
|
371
|
+
|
372
|
+
@app_commands.command(name="embed", description="Cria um embed")
|
373
|
+
@app_commands.checks.has_permissions(manage_webhooks=True)
|
374
|
+
@app_commands.describe(
|
375
|
+
template="Um template do embed que será editado"
|
376
|
+
)
|
377
|
+
async def embedcmd(self, interaction: discord.Interaction, template: str = None):
|
378
|
+
content = "Conteúdo"
|
379
|
+
embed = discord.Embed(title="Título", description="Descrição")
|
380
|
+
embed.set_author(name=interaction.user.name, icon_url=interaction.user.avatar.url if interaction.user.avatar else interaction.user.default_avatar.url)
|
381
|
+
embed.set_thumbnail(url=interaction.guild.icon.url)
|
382
|
+
embed.set_footer(text=interaction.guild.name, icon_url=interaction.guild.icon.url)
|
383
|
+
|
384
|
+
if template:
|
385
|
+
try:
|
386
|
+
if template.startswith("{") and template.endswith("}"):
|
387
|
+
data: dict = json.loads(template)
|
388
|
+
|
389
|
+
embed = discord.Embed(
|
390
|
+
title=data.get("title", "Título"),
|
391
|
+
description=data.get("description", "Descrição"),
|
392
|
+
color=int(data.get("color", "#ffffff").lstrip("#"), 16)
|
393
|
+
)
|
394
|
+
|
395
|
+
content=data.get("content")
|
396
|
+
|
397
|
+
if "author" in data:
|
398
|
+
author = data["author"]
|
399
|
+
embed.set_author(
|
400
|
+
name=author.get("name", ""),
|
401
|
+
url=author.get("url", ""),
|
402
|
+
icon_url=author.get("icon_url", "")
|
403
|
+
)
|
404
|
+
|
405
|
+
if "thumbnail" in data:
|
406
|
+
embed.set_thumbnail(url=data["thumbnail"].get("url", ""))
|
407
|
+
|
408
|
+
if "image" in data:
|
409
|
+
embed.set_image(url=data["image"].get("url", ""))
|
410
|
+
|
411
|
+
if "footer" in data:
|
412
|
+
footer = data["footer"]
|
413
|
+
embed.set_footer(
|
414
|
+
text=footer.get("text", ""),
|
415
|
+
icon_url=footer.get("icon_url", "")
|
416
|
+
)
|
417
|
+
|
418
|
+
for field in data.get("fields", []):
|
419
|
+
embed.add_field(
|
420
|
+
name=field.get("name", "Sem Nome"),
|
421
|
+
value=field.get("value", "Sem Valor"),
|
422
|
+
inline=field.get("inline", True)
|
423
|
+
)
|
424
|
+
else:
|
425
|
+
template = template.split("/")
|
426
|
+
canal = self.bot.get_channel(int(template[-2])) if len(template) > 1 else interaction.channel
|
427
|
+
msg = await canal.fetch_message(int(template[-1]))
|
428
|
+
embed = msg.embeds[0]
|
429
|
+
content = msg.content
|
430
|
+
except json.JSONDecodeError:
|
431
|
+
return await interaction.response.send_message("O JSON fornecido não é válido. Verifique a formatação.", ephemeral=True)
|
432
|
+
except ValueError:
|
433
|
+
return await interaction.response.send_message("O template fornecido não é válido. Certifique-se de que contém IDs numéricos ou um JSON correto.", ephemeral=True)
|
434
|
+
except discord.NotFound:
|
435
|
+
return await interaction.response.send_message("A mensagem ou o canal especificado não foi encontrado.", ephemeral=True)
|
436
|
+
except discord.Forbidden:
|
437
|
+
return await interaction.response.send_message("O bot não tem permissão para acessar o canal ou a mensagem.", ephemeral=True)
|
438
|
+
except Exception as e:
|
439
|
+
return await interaction.response.send_message(f"Ocorreu um erro inesperado: {str(e)}", ephemeral=True)
|
440
|
+
await interaction.response.defer(ephemeral=True)
|
441
|
+
await interaction.followup.send(content=content, embed=embed, ephemeral=True)
|
442
|
+
msg = await interaction.original_response()
|
443
|
+
await msg.edit(view=EmbedGenerator(msg))
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: embed_model
|
3
|
+
Version: 0.1
|
4
|
+
Summary: Um modelo de embeds não oficial para discord.py. Feito em Português.
|
5
|
+
Home-page: https://github.com/LucaCunha001/DiscordEmbedModel
|
6
|
+
Author: Luca Cunha (Frisk)
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
11
|
+
Requires-Python: >=3.8
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
Requires-Dist: discord
|
14
|
+
Dynamic: author
|
15
|
+
Dynamic: classifier
|
16
|
+
Dynamic: description
|
17
|
+
Dynamic: description-content-type
|
18
|
+
Dynamic: home-page
|
19
|
+
Dynamic: requires-dist
|
20
|
+
Dynamic: requires-python
|
21
|
+
Dynamic: summary
|
22
|
+
|
23
|
+
# 📦 Discord Embed Editor Bot
|
24
|
+
|
25
|
+
Um modelo para Discord que permite editar embeds de mensagens de forma interativa utilizando **modais**, **botões** e **menus de seleção** da UI do Discord. Ideal para quem deseja personalizar mensagens de maneira rápida, visual e organizada.
|
26
|
+
|
27
|
+
## ✨ Funcionalidades
|
28
|
+
|
29
|
+
- 📑 Editar título, descrição, conteúdo e cor do embed.
|
30
|
+
- 🖼️ Definir ou alterar thumbnail, imagem principal e timestamp.
|
31
|
+
- 👣 Editar o footer (texto e imagem).
|
32
|
+
- ➕ Adicionar novos fields (campos) ao embed.
|
33
|
+
- ✏️ Editar campos existentes.
|
34
|
+
- 🗑️ Remover campos específicos.
|
35
|
+
- ✅ Confirmar e enviar embeds editados.
|
36
|
+
- ❌ Cancelar e excluir mensagens temporárias de edição.
|
37
|
+
|
38
|
+
## 📦 Tecnologias Utilizadas
|
39
|
+
|
40
|
+
- [Python 3.11+](https://www.python.org/)
|
41
|
+
- [discord.py 2.x](https://discordpy.readthedocs.io/en/stable/)
|
42
|
+
- Componentes interativos: `discord.ui.Modal`, `discord.ui.Button`, `discord.ui.Select`
|
43
|
+
|
44
|
+
## 🚀 Como usar
|
45
|
+
|
46
|
+
1. Clone o repositório:
|
47
|
+
```bash
|
48
|
+
git clone https://github.com/LucaCunha001/DiscordEmbedModel.git
|
49
|
+
cd DiscordEmbedModel.git
|
@@ -0,0 +1,6 @@
|
|
1
|
+
embed-model/__init__.py,sha256=GPy9PjPYdp9Bkk2q7-Ax6OWN6vvVf2gMN0qwKuSWczE,20
|
2
|
+
embed-model/modulo.py,sha256=Z3_Is6T3PxU5QXO4i7t-L40MlDlcAqS3Eti77yxADFo,18431
|
3
|
+
embed_model-0.1.dist-info/METADATA,sha256=hrR1EoJPXjQjJkCWwEViWIeCOFS0Jsrv7OQyZaHlxiY,1832
|
4
|
+
embed_model-0.1.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
5
|
+
embed_model-0.1.dist-info/top_level.txt,sha256=BMVZvF1OWDwZ2kdzYyme1WLJRwEYD1zCdR5cZc0dw2w,12
|
6
|
+
embed_model-0.1.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
embed-model
|