-
Hello there! I am trying to write my own bot using discord.py's Cogs (more specifically GroupCogs) and App Commands. I consulted the Cogs documentation and examples, the GroupCog documentation, the Group documentation, the app_commands.command() documentation, and this discussion before finally settling on code which resembles the following: import discord
from discord.ext import commands
TOKEN = '{insert_token_here}'
INTENTS = discord.Intents.default()
INTENTS.message_content = True
BOT = commands.Bot(command_prefix='/', intents=INTENTS)
class Test(commands.GroupCog, group_name='test'):
def __init__(self, bot):
self.bot = bot
@discord.app_commands.command()
async def ping(self, interaction: discord.Interaction):
await interaction.response.send_message("Pong.")
@BOT.event
async def on_ready():
await BOT.add_cog(Test(BOT))
await BOT.tree.sync()
#print(BOT.tree.get_commands())
#print(BOT.get_cog('Test').app_command)
#print(BOT.get_cog('Test').app_command.commands)
#print(BOT.get_cog('Test').get_app_commands())
BOT.run(TOKEN) Unfortunately, both my code and the above example do not seem to work. Whenever I try to run a command in my guild (e.g. From what I can tell, the test group is recognized and added to the bot's command tree, the Test GroupCog recognizes its Group, and that Group recognizes the command it contains. However, the GroupCog does not list any commands when I call I am running the above test code on Windows 11 with Python version 3.11.9 and discord.py version 2.4.0. Am I doing something wrong, or is something not working as intended here? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It is advised against setting the prefix to The error you encountered occurs because the library is attempting to find a prefix command named Here are some debugging steps to help troubleshoot (copied from
If you're still unable to resolve the issue, consider joining the support server and creating a help post there. |
Beta Was this translation helpful? Give feedback.
Thank you for the quick response!
I followed your troubleshooting steps- none of them in particular were my exact problem, but I did find the issue while investigating the bot's Integrations page. The issue was that my bot did not have the Use Slash Commands permission, even though it did have the applications.commands scope.
I suppose my confidence got the best of me, and I assumed I would be able to setup a new bot without referencing the setup instructions this time.
Thank you for pointing me in the right direction, and for your time!