I've used snippet codes from the nextcord tutorials section just to get the basic cog working
When I try to do the slash command it doesn't work and the bot reports 0 errors and Cog loaded successfully!
class Test(Cog):
def __init__(self, bot: Bot) -> None:
self.bot = bot
slash_command(name="ping", description="A simple ping command.", guild_ids=[...])
async def test(self, inter: Interaction) -> None:
await inter.send(f"Pong! {self.bot.latency * 1000:.2f}ms")
def setup(bot: Bot) -> None:
bot.add_cog(Test(bot))
from dotenv import load_dotenv
import os
from nextcord.ext.commands import Bot
load_dotenv()
intents = nextcord.Intents.default()
intents.message_content = True
bot = Bot()
# Event: on_ready
@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')
try:
bot.load_extension('cogs.Test')
print("Cog loaded successfully!")
except Exception as e:
print(f"Error loading cog: {e}")
bot.run(os.getenv('TOKEN'))