Lucas Tesch
Lucas Tesch

Reputation: 157

How to check a list of all commands from discord

I'm trying to check If some argument is a command from my server

async def test(self, ctx, *, cmd: str):

    if cmd in self.bot.commands:

What should I do? The self.bot.commands get a list of commands objects not the names..

Upvotes: 0

Views: 3354

Answers (1)

Deru
Deru

Reputation: 1173

The documentation says that self.bot.commands returns a list of commands. One such command object has a name attribute. So you can create a function to check if the message (name) corresponds with a name of an existing command:

def command_name_exists(name):
    for command in self.bot.commands:
        if name == command.name:
            return True
    return False

Upvotes: 1

Related Questions