#Cogs
1 messages ยท Page 1 of 1 (latest)
can you show me where you define astral?
the problem most likely is that, whatever class astral is, it doesn't actually inherit from commands.Cog, as your error states
from disnake.ext import commands
from utils.color import color
global starttime
starttime = disnake.utils.utcnow()
class astral(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.slash_command(
name="astral",
description="uptime"
)
async def astral(self, interaction):
pass
@astral.sub_command(
name="uptime",
description="displays the bot uptime",
)
async def uptime(self, interaction: disnake.ApplicationCommandInteraction):
endtime = disnake.utils.utcnow()
diff = endtime - starttime
seconds = diff.seconds % 60
minutes = (diff.seconds // 60) % 60
hours = (diff.seconds // 3600) % 24
days = diff.days
embed = disnake.Embed(
title="Bot Uptime ๐",
description=f"{days} days, {hours} hours, {minutes} minutes, {seconds} seconds",
color=color,
timestamp=disnake.utils.utcnow(),
)
await interaction.send(embed=embed)
Hey @brittle zinc!
It looks like you incorrectly specified a language for your code block.
Make sure you put your code on a new line following py. There must not be any spaces after py.
Here is an example of how it should look:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
but your function names should not match the class names, either
what do you mean
You have class astral(...)
then a command function called astral(self, inter...)
Class names should typically be CamelCase
class Astral(commands.Cog)
that would make them separate if you don't want to change the function name
also.. your uptime function could be completely reduced to just
embed = disnake.Embed(
title="Bot Uptime ๐",
description=f'{disnake.utils.format_dt(starttime, 'R')},
color=color,
timestamp=disnake.utils.utcnow(),
)
So it would appear as:
<t:1663492215:R>
i do not understand what 'R' does?
+-------------+----------------------------+-----------------+
| Style | Example Output | Description |
+=============+============================+=================+
| t | 22:57 | Short Time |
+-------------+----------------------------+-----------------+
| T | 22:57:58 | Long Time |
+-------------+----------------------------+-----------------+
| d | 17/05/2016 | Short Date |
+-------------+----------------------------+-----------------+
| D | 17 May 2016 | Long Date |
+-------------+----------------------------+-----------------+
| f (default) | 17 May 2016 22:57 | Short Date Time |
+-------------+----------------------------+-----------------+
| F | Tuesday, 17 May 2016 22:57 | Long Date Time |
+-------------+----------------------------+-----------------+
| R | 5 years ago | Relative Time |
+-------------+----------------------------+-----------------+
oh
like this:
Just showing other options
but did that fix your issue?
Want to make sure that is done before you worry about something else that's working
it did fix it
and thats awesome
ive made bots before
and i really just wanted to compile all of my python knowledge into this
and its been a decently long time since i touched disnake
and im a bit rusty
thank you though
yup ofc