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
| Field | JS Type | Python Type | Required | Description |
|---|---|---|---|---|
command | string | str | â Yes | The command name (e.g., "play") |
userId / user_id | string | str | No | Discord user ID |
guildId / guild_id | string | str | No | Guild/server ID |
guildName / guild_name | string | str | No | Human-readable server name |
locale | string | str | No | The 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.