Application Commands#

What are application commands?

In the words of discord:

“Application commands are commands that an application (bot) can register to Discord. They provide users a first-class way of interacting directly with your application that feels deeply integrated into Discord.”

Examples of application commands include:

Important Information:

As Discord has decided to ban bots from reading messages without the intent enabled, you should be using application commands wherever possible.

You should at least have a basic understanding of:

For an example slash command, see the examples directory


Note that by default, application commands will be global unless you specify a set of guilds that they should be created in using BotApp.default_enabled_guilds or by passing a set of guilds into the @lightbulb.command decorator. Global commands will take up to one hour to sync to discord, so it is reccommended that you use guild-specific commands during development and testing.

Creating a Basic Slash Command#

Slash commands (and other application command types) are implemented exactly the same way as prefix commands. You just replace the commands.PrefixCommand with commands.SlashCommand in the @lightbulb.implements decorator.

See Below

import lightbulb

bot = lightbulb.BotApp(...)

@lightbulb.command("ping", "checks that the bot is alive")
async def ping(ctx: lightbulb.Context) -> None:
    await ctx.respond("Pong!")

Adding options to slash commands is also identical to how you add options to prefix commands

import lightbulb

bot = lightbulb.BotApp(...)

@lightbulb.option("text", "text to repeat")
@lightbulb.command("echo", "repeats the given text")
async def echo(ctx: lightbulb.Context) -> None:
    await ctx.respond(ctx.options.text)

To create message or user commands you need to add commands.MessageCommand and commands.UserCommand respectively to the @lightbulb.implements decorator. You should note that message and user commands cannot take any options, however the target of the command will always be stored in the option target. Any option decorators added to context menu commands will be ignored.