-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashtagstuff.rtf
49 lines (41 loc) · 2.14 KB
/
hashtagstuff.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@client.command()
async def paleta(ctx, num_colors: int = None):
if num_colors is None:
num_colors = random.randint(4, 8)
response = requests.get(f"https://lospec.com/palette-list/json?count={num_colors}random=true")
if response.status_code != 200:
await ctx.send("Hubo un error al obtener la paleta de colores. Por favor, inténtalo de nuevo más tarde.")
return
data = response.json()
if data.get("error"):
await ctx.send("No se encontró ninguna paleta con esa cantidad de colores. Por favor, elige una cantidad diferente.")
#return
palette = data[0]
color_palette = palette["colors"]
palette_name = palette["name"]
palette_creator = palette["author"]
image = Image.new("RGBA", (1020, 400), (255, 255, 255, 0))
#draw = ImageDraw.Draw(image)
x, y = 0, 0
width = (1000 - (12 * (num_colors - 1))) // num_colors
radius = 20
for color in color_palette:
draw.rounded_rectangle((x, y, x+width, y+396), radius, fill=color)
x += width + 14
image.save("LOSPEC_palette.png")
embed = discord.Embed(title=palette_name, description=f"La paleta de colores llamada {palette_name} fue creada por {palette_creator} y tiene {num_colors} colores diferentes. Cada uno de estos colores ha sido cuidadosamente seleccionado y combinado para crear una paleta única y atractiva. ¡Hazle honor a esta paleta en tu próximo dibujo!", color=0xff42e6)
embed.add_field(name="Creador de la paleta:", value=palette_creator, inline=False)
embed.set_image(url="attachment://LOSPEC_palette.png")
with open("LOSPEC_palette.png", "rb") as f:
await ctx.send(file=discord.File(f, filename="LOSPEC_palette.png"), embed=embed)
os.remove("LOSPEC_palette.png")
num_colors = random.randint(4, 8)
response = requests.get(f"https://lospec.com/palette-list/load?colorNumberFilterType=exact&colorNumber={num_colors}&page=0&tag=&sortingType=default")
@client.command()
async def paleta(ctx):
data = response.json()
palette = data["palettes"][0]
slug = palette["slug"]
title = slug.split("-")[-1].strip()
print(palette, slug, title)
ctx.send(data)