diff --git a/README.md b/README.md index 9a5d453..5812d6b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ## Commands -![Total Commands](https://img.shields.io/badge/Total%20Commands-68-5865F2) +![Total Commands](https://img.shields.io/badge/Total%20Commands-69-5865F2) | Command group | Subcommands | | ------------ | --- | @@ -30,7 +30,7 @@ | sidestore | `help`, `refresh`, `code`, `crash`, `pairing`, `server`, `half`, `sparse`, `afc`, `udid` | | idevice | `help`, `noapps`, `errorcode`, `developermode`, `mountddi` | | melonx | `help`, `transfer`, `mods`, `gamecrash`, `requirements`, `error`, `26` | -| miscellaneous | `keanu`, `labubu`, `piracy`, `tryitandsee`, `rickroll`, `dontasktoask`, `support`, `depart`, `docs` `sigma`, `duck`, `silly` | +| miscellaneous | `keanu`, `labubu`, `piracy`, `tryitandsee`, `rickroll`, `dontasktoask`, `support`, `depart`, `docs` `sigma`, `duck`, `silly`, `color` | | utilities | `translate`, `codepreview`, `dictionary` | | media | `download`, `mcquote`, `img2gif`, `tweety`, `tts` | diff --git a/TODO.md b/TODO.md index 27d97ee..92340f8 100644 --- a/TODO.md +++ b/TODO.md @@ -43,7 +43,7 @@ - [ ] Add sending code (regular and from github) -- [ ] Add random color command +- [x] Add random color command - [x] Add translate command diff --git a/cogs/botinfo.py b/cogs/botinfo.py index 994abc2..8f71cc9 100644 --- a/cogs/botinfo.py +++ b/cogs/botinfo.py @@ -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" diff --git a/cogs/miscellaneous/__init__.py b/cogs/miscellaneous/__init__.py index 499c8b5..780936e 100644 --- a/cogs/miscellaneous/__init__.py +++ b/cogs/miscellaneous/__init__.py @@ -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'") \ No newline at end of file diff --git a/cogs/miscellaneous/color.py b/cogs/miscellaneous/color.py new file mode 100644 index 0000000..76db1a1 --- /dev/null +++ b/cogs/miscellaneous/color.py @@ -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 \ No newline at end of file