#Cogs

1 messages ยท Page 1 of 1 (latest)

brittle zinc
#

does this mean i have to bot.load_ext from all of the files

wispy prairie
#

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

brittle zinc
# wispy prairie can you show me where you define astral?
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)
mental lionBOT
#

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.
brittle zinc
#

this is the entire cog

#

im sorry for answering so late

#

i went out

brave mauve
#

you need to pass the bot to the cog.

#

bot.add_cog(astral(bot))

brittle zinc
#

ahh

#

thank you

brave mauve
#

but your function names should not match the class names, either

brittle zinc
#

what do you mean

brave mauve
#

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(),
)
brittle zinc
#

oh okay

#

but

brave mauve
#

So it would appear as:
<t:1663492215:R>

brittle zinc
#

i do not understand what 'R' does?

brave mauve
#
    +-------------+----------------------------+-----------------+
    |    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   |
    +-------------+----------------------------+-----------------+
brittle zinc
#

oh

brave mauve
#

just an option.

#

Though, your way works, too

brittle zinc
#

wow

#

no

#

i like this way

#

thank you so much

brave mauve
#

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

brittle zinc
#

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

brave mauve
#

No worries ๐Ÿ˜„

#

glad it's solved

brittle zinc
#

yup ofc