Skip to content

Commit

Permalink
Merge pull request #158 from korbosoft/patch-1
Browse files Browse the repository at this point in the history
Add random color functionality
  • Loading branch information
h-anjru authored May 16, 2024
2 parents 09abe19 + e482c86 commit 9c2aa31
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crimsobot/cogs/utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import logging
from datetime import datetime
from random import randint
from typing import List, Optional, Tuple

import discord
Expand Down Expand Up @@ -169,9 +170,11 @@ async def ping(self, ctx: commands.Context) -> None:
await msg.edit(content='<:ping:569954524932997122>...{:d}ms'.format(int(ping)))

@commands.command()
async def color(self, ctx: commands.Context, hex_value: discord.Colour) -> None:
"""Get color sample from hex value."""
async def color(self, ctx: commands.Context, hex_value: Optional[discord.Colour] = None) -> None:
"""Get color sample from hex value, or generate random color if not given input."""

if hex_value is None:
hex_value = '#%06x' % randint(0, 0xFFFFFF)
fp = imagetools.make_color_img(str(hex_value))
await ctx.send(
'**' + str(hex_value) + '**',
Expand Down

0 comments on commit 9c2aa31

Please sign in to comment.