Tracking Commands

Cordia is built for modern Discord bots. We recommend using our Zero-Effort Helpers to automatically track Slash Commands and Prefix Commands with full metadata (Server Names, Locales, etc.).

The Recommended Way (Zero-Effort)

These helpers automatically extract all necessary information directly from Discord objects.

Slash Commands (Interactions)

Compatible with discord.js, discord.py, and disnake.

JavaScript (discord.js)
typescript
client.on('interactionCreate', (interaction) => {
  if (interaction.isCommand()) {
    // 🚀 Tracks command name, user, server name, and locale automatically
    cordia.trackInteraction(interaction);
  }
});
Python (discord.py)
python
@bot.tree.command()
async def play(interaction: discord.Interaction):
    # 🚀 Zero setup: handles all metadata extraction
    await cordia.track_interaction(interaction)
    await interaction.response.send_message("Playing!")

Prefix Commands (Messages)

JavaScript (discord.js)
typescript
client.on('messageCreate', (message) => {
  if (message.author.bot || !message.content.startsWith('!')) return;

  const command = message.content.slice(1).split(' ')[0];
  
  // 🚀 Tracks user and server info automatically
  cordia.trackMessage(message, command);
});
Python (discord.py)
python
@bot.command()
async def play(ctx):
    # 🚀 Simply pass the message and command name
    await cordia.track_message(ctx.message, 'play')
    await ctx.send("Playing!")

Manual Tracking (Advanced)

If you need custom logic, you can manually map fields using trackCommand.

JavaScript / TypeScript

Manual command tracking
typescript
cordia.trackCommand({
  command: 'play',
  userId: '123456789',
  guildId: '987654321',
  guildName: 'My Server',
  locale: 'en-US'
});

Python

Manual command tracking
python
await cordia_client.track_command(
    command="play",
    user_id="123456789",
    guild_id="987654321",
    guild_name="My Server",
    locale="en-US"
)

Payload Reference

FieldJS TypePython TypeRequiredDescription
commandstringstr✅ YesThe command name (e.g., "play")
userId / user_idstringstrNoDiscord user ID
guildId / guild_idstringstrNoGuild/server ID
guildName / guild_namestringstrNoHuman-readable server name
localestringstrNoThe user's language setting (e.g., "en-US")
â„šī¸Error Handling
If the command name is empty or invalid, the SDK will log a warning but will never throw an error or crash your bot.