Get all bot commands discord.py

Question:

I’m making a help command using discord.py rewrite and I need a way to iterate over all the commands I already have inside the bot, is there a way to do like bot.get_all_commands?

for command in bot.get_all_commands:
    print(command)
Asked By: Haisi

||

Answers:

bot.commands returns all commands as command objects in a set.

Answered By: chluebi

You can use bot.all_commands to return all commands & aliases that you used before, See more in discord.ext.command .

Answered By: Mr.B Developer

This worked for me

commands = bot.get_my_commands()
for command in commands:
    print(command)
Answered By: nazario

With version 2.0.0 and above, to get all commands we also need to get the new app command as well. Use the bot.walk_commands() method instead of bot.commands to get those under a group.

I’ve done it with this function:

def get_all_commands(bot):
    return [
        *bot.walk_commands(),
        *bot.tree.walk_commands()
    ]
Answered By: Apollo-Roboto
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.