Commands
Defining commands
Section titled “Defining commands”Use @bot.command() for inline definitions or @cog_command() inside a Cog:
from cordless import Cordless
bot = Cordless()
@bot.command("ping", description="Check latency")async def ping(ctx): await ctx.send("Pong!")With a Cog
Section titled “With a Cog”from cordless import Cog, cog_command
class MyCog(Cog): @cog_command("hello", description="Say hello") async def hello(self, ctx): await ctx.send(f"Hello, {ctx.user['username']}!")bot.add_cog(MyCog())Options
Section titled “Options”from cordless import Option, OptionType
@bot.command("greet", description="Greet a user", options=[ Option("name", "Who to greet", OptionType.STRING, required=True),])async def greet(ctx): name = ctx.options.get("name", "stranger") await ctx.send(f"Hey, {name}!")Deferred commands
Section titled “Deferred commands”For commands that take more than 3 seconds, set defer=True. Requires defer_worker in cordless.toml.
@cog_command("slow", description="Takes a while", defer=True)async def slow(self, ctx): result = await do_something_slow() await ctx.send(result)Registering
Section titled “Registering”cordless register lambda_function:bot --token YOUR_BOT_TOKEN
# Guild-only (faster propagation, for testing)cordless register lambda_function:bot --token YOUR_BOT_TOKEN --guild-id YOUR_GUILD_ID