mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
feat(color): new command :)
Co-authored-by: neo <email@neoarz.dev> Co-authored-by: neoarz <tyrantneo740@gmail.com>
This commit is contained in:
@@ -96,7 +96,7 @@ class BotInfo(commands.Cog, name="botinfo"):
|
||||
current_time = datetime.now(ny_tz).strftime("%m/%d/%y, %I:%M %p")
|
||||
|
||||
description_text = (
|
||||
"Heyooo! Im Syntrel, a bot made to help with [SideStore](https://discord.gg/3DwCwpBHfv), [MeloNX](https://discord.gg/Q4VkbkYfmk), and [idevice](https://discord.gg/ZnNcrRT3M8). I even have some cool extras! If you encounter any issues, please file a bug report. If you have any feedback or suggestions, simply select \"Feedback\"! <:HeardPanda:1417619745896660992>\n\n"
|
||||
"Heyooo! I'm Syntrel, a bot made to help with [SideStore](https://discord.gg/3DwCwpBHfv), [MeloNX](https://discord.gg/Q4VkbkYfmk), and [idevice](https://discord.gg/ZnNcrRT3M8). I even have some cool extras! If you encounter any issues, please file a bug report. If you have any feedback or suggestions, simply select \"Feedback\"! <:HeardPanda:1417619745896660992>\n\n"
|
||||
"**New to Syntrel?** Run `/help` to get started and explore all available commands!\n\n"
|
||||
f"**Owner:** [neoarz](https://discordapp.com/users/1015372540937502851)\n"
|
||||
f"**Python Version:** {platform.python_version()}\n"
|
||||
|
||||
@@ -15,6 +15,7 @@ from .support import support_command
|
||||
from .docs import docs_command
|
||||
from .sigma import sigma_command
|
||||
from .silly import silly_command
|
||||
from .color import color_command
|
||||
|
||||
|
||||
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
|
||||
@@ -32,7 +33,7 @@ class Miscellaneous(commands.GroupCog, name="misc"):
|
||||
color=0x7289DA
|
||||
)
|
||||
embed.set_author(name="Miscellaneous", icon_url="https://yes.nighty.works/raw/YxMC0r.png")
|
||||
embed.add_field(name="Available", value="dontasktoask, rr, depart, labubu, duck, tryitandsee, piracy, keanu, support, docs, sigma, silly", inline=False)
|
||||
embed.add_field(name="Available", value="dontasktoask, rr, depart, labubu, duck, tryitandsee, piracy, keanu, support, docs, sigma, silly, color", inline=False)
|
||||
await context.send(embed=embed)
|
||||
|
||||
async def _invoke_hybrid(self, context: Context, name: str):
|
||||
@@ -100,6 +101,10 @@ class Miscellaneous(commands.GroupCog, name="misc"):
|
||||
async def miscellaneous_group_silly(self, context: Context, message_type: str = "regular"):
|
||||
await self._invoke_hybrid(context, "silly", message_type=message_type)
|
||||
|
||||
@miscellaneous_group.command(name="color")
|
||||
async def miscellaneous_group_color(self, context: Context):
|
||||
await self._invoke_hybrid(context, "color")
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="dontasktoask",
|
||||
@@ -203,6 +208,14 @@ class Miscellaneous(commands.GroupCog, name="misc"):
|
||||
async def silly(self, context, message_type: str = "regular"):
|
||||
return await silly_command()(self, context, message_type=message_type)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="color",
|
||||
description="Get a random color."
|
||||
)
|
||||
async def color(self, context):
|
||||
return await color_command()(self, context)
|
||||
|
||||
async def setup(bot) -> None:
|
||||
cog = Miscellaneous(bot)
|
||||
await bot.add_cog(cog)
|
||||
@@ -219,3 +232,4 @@ async def setup(bot) -> None:
|
||||
bot.logger.info("Loaded extension 'miscellaneous.docs'")
|
||||
bot.logger.info("Loaded extension 'miscellaneous.sigma'")
|
||||
bot.logger.info("Loaded extension 'miscellaneous.silly'")
|
||||
bot.logger.info("Loaded extension 'miscellaneous.color'")
|
||||
36
cogs/miscellaneous/color.py
Normal file
36
cogs/miscellaneous/color.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import random
|
||||
import colorsys
|
||||
|
||||
def color_command():
|
||||
@commands.hybrid_command(name="color", description="Get a random color.")
|
||||
async def color(self, context):
|
||||
"""
|
||||
Generates a random color and displays information about it.
|
||||
"""
|
||||
random_color_int = random.randint(0, 0xFFFFFF)
|
||||
color = discord.Color(random_color_int)
|
||||
|
||||
r, g, b = color.r, color.g, color.b
|
||||
|
||||
rgb_decimal = (r / 255, g / 255, b / 255)
|
||||
|
||||
h, l, s = colorsys.rgb_to_hls(rgb_decimal[0], rgb_decimal[1], rgb_decimal[2])
|
||||
h_hsv, s_hsv, v_hsv = colorsys.rgb_to_hsv(rgb_decimal[0], rgb_decimal[1], rgb_decimal[2])
|
||||
|
||||
embed = discord.Embed(title="Random Color", color=color)
|
||||
|
||||
embed.add_field(name="Hex", value=str(color))
|
||||
embed.add_field(name="RGB", value=f"rgb({r}, {g}, {b})")
|
||||
embed.add_field(name="RGB Decimal", value=f"{rgb_decimal[0]:.3f}, {rgb_decimal[1]:.3f}, {rgb_decimal[2]:.3f}")
|
||||
|
||||
embed.add_field(name="HSL", value=f"hsl({h*360:.0f}, {s*100:.0f}%, {l*100:.0f}%)")
|
||||
embed.add_field(name="HSV", value=f"hsv({h_hsv*360:.0f}, {s_hsv*100:.0f}%, {v_hsv*100:.0f}%)")
|
||||
embed.add_field(name="Integer", value=str(random_color_int))
|
||||
|
||||
embed.set_thumbnail(url=f"https://singlecolorimage.com/get/{str(color).replace('#', '')}/150x150")
|
||||
|
||||
await context.send(embed=embed)
|
||||
|
||||
return color
|
||||
Reference in New Issue
Block a user