#How to use slash command using cogs?

1 messages · Page 1 of 1 (latest)

split parrot
#

i dont know how i should use slash command using cogs. does someone know its answer? please let me know.

deft larkBOT
#

Here's the slash cog example.

#

Here's the slash cog groups example.

dapper rivet
#

@split parrot check those

split parrot
#

umm i have checked those , but i cant use it yet.

heady kayak
split parrot
#

aiohttp 3.8.1
aiosignal 1.2.0
astunparse 1.6.3
async-timeout 4.0.2
attrs 22.1.0
braceexpand 0.1.7
CacheControl 0.12.11
cachetools 5.2.0
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 2.1.1
click 8.1.3
colorama 0.4.6
cryptography 38.0.4
ffmpeg-python 0.2.0
firebase-admin 6.0.1
Flask 2.2.2
frozenlist 1.3.1
future 0.18.2
google-api-core 2.11.0
google-api-python-client 2.70.0
google-auth 2.15.0
google-auth-httplib2 0.1.0
google-cloud-core 2.3.2
google-cloud-firestore 2.7.3
google-cloud-storage 2.7.0
google-crc32c 1.5.0
google-resumable-media 2.4.0
googleapis-common-protos 1.57.0
grpcio 1.51.1
grpcio-status 1.51.1
httplib2 0.21.0
idna 3.3
imageio-ffmpeg 0.4.7
import-expression 1.1.4
importlib-metadata 5.2.0
itsdangerous 2.1.2
Jinja2 3.1.2
jishkucord 2.5.2
line-profiler 4.0.2
MarkupSafe 2.1.1
msgpack 1.0.4
multidict 6.0.2
numpy 1.23.3
pip 22.3.1
proto-plus 1.22.1
protobuf 4.21.12
py-cord 2.1.1
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycord 0.1.1
pycparser 2.21
PyJWT 2.6.0
pymongo 4.2.0
pyparsing 3.0.9
requests 2.28.1
rsa 4.9
setuptools 41.2.0
six 1.16.0
typing_extensions 4.4.0
uritemplate 4.1.1
urllib3 1.26.13
Werkzeug 2.2.2
wheel 0.38.4
yarl 1.8.1
zipp 3.11.0

dapper rivet
split parrot
#

i cant use the slashcommand

heady kayak
split parrot
#
# ticket.py

import discord
from discord.ext import commands


class Example(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.slash_command(name='hi')
    async def hi(self, ctx: discord.ApplicationContext):
        await ctx.respond('hello')


def setup(bot):
    bot.add_cog(Example(bot))
#
@bot.event
async def on_ready():
    print('Bot is ready.')
    bot.load_extension('cogs.ticket')
heady kayak
#

you load the cog at on_ready...

split parrot
#

🤔

#

i cant understand what you are saying

heady kayak
#

do you know basic python?

split parrot
#

yeah

heady kayak
#

if you load the cog at the on_ready event, it will not work

split parrot
#

so what should i do to make bot load the extension

heady kayak
#

remove if from the on_ready event

split parrot
#

well, i tried it but it doesn't work well

heady kayak
#

?tag idw

swift sierraBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

split parrot
#
# main file
@bot.event
async def on_ready():
    print('Monde Bot is ready.')
import discord
from discord.ext import commands


class Example(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.slash_command(name='hi')
    async def hi(self, ctx: discord.ApplicationContext):
        await ctx.respond('hello')


def setup(bot):
    bot.add_cog(Example(bot))
heady kayak
#

the whole main file pls

split parrot
heady kayak
#

oof