I cant see any slash commands

35 Views Asked by At

Im using cogs in my pycord bot and have made slash commands but i cant see them

this is my main file where the bot runs:

main.py

import tracemalloc
tracemalloc.start()

import os
import pathlib

import discord
from discord.ext import commands
from discord import option
from dotenv import load_dotenv
load_dotenv()

CMDS_PATH = pathlib.Path(__file__).parent / "cmds"

intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(intents=intents)
bot.auto_sync = True

@bot.event
async def on_ready():
    print(f'{bot.user} has connected to Discord!')

    for cmd_file in CMDS_PATH.glob("*.py"):
        if cmd_file.name != "__init__.py":
            bot.load_extension(f"cmds.{cmd_file.name[:-3]}")

bot.run(os.getenv("TOKEN"))

this is my test cog which is in the "cogs" folder

cogs/hello.py

import discord
from discord.ext import commands

class test(commands.Cog):
    def __init__(self, bot: discord.Bot):
        self.bot = bot

    @commands.slash_command()
    async def hello(self, ctx): 
        await ctx.defer(ephemeral=True)
        await ctx.respond("hello", ephemeral=True)

def setup(bot: discord.Bot):
    bot.add_cog(test(bot))

does anybody know why i cant see the slash commands?? i first tried syncing but got told that syncing isnt needed anymore in pycord since it automaticly synces

0

There are 0 best solutions below