""" This is a utils cog, this is general utils that exist to be helpful. -- Ping command forked from same repo as main.py -- """ import time import discohook import calendar @discohook.command.slash('ping', description = 'Ping test the bot!') async def ping_command(interaction): created_at = interaction.created_at now = time.time() since = now - created_at text = '\n'.join([ 'Pong! Latency: `{:.2f}ms`'.format(since * 1000), '', 'Bot started at: {}'.format(interaction.client.started_at.timestamp()), 'Interaction created at: {}'.format(created_at), 'Time right now: {}'.format(now) ]) await interaction.response.send(text) @discohook.command.slash('timestamp', description='Get a timestamp that converts into any viewer\'s timezone.', options=[discohook.Option.string("date", "A date in MM/DD/YYYY/HH/MM format. Give it in UTC, and in 24 hr format.", required=True)]) async def timestamp_command(interaction, date: str): try: timestamp = time.strptime(date, "%m/%d/%Y/%H/%M") except Exception: await interaction.response.send("Oops! Looks like an error occured...\nTry checking your inputs over again?") return timestamp = calendar.timegm(timestamp) text = '\n'.join([ 'Copy the timestamp you need below:', f'', f'', f'', f'', f'', f'', f'', f'', f'' ]) await interaction.response.send(text) @discohook.command.slash('info', description="Info on the bot") async def info_command(interaction: discohook.Interaction): embed = discohook.Embed("Byte", description="I'm a open source discord bot hosted on a serverless platform.", color=0xffffff) embed.set_footer("I'm serverless, so I might drop your commands if I take too long.") embed.add_field("Git Repo", "https://tangled.org/aesth.lol/byte") await interaction.response.send(embed=embed)