Getting started

For developers comfortable with Node and TypeScript. If you are new, start with Your first bot instead.

For developers comfortable with Node and TypeScript. If you are new, start with Your first bot instead.

Install

npm install athena
npm install zlib-sync   # optional: gateway compression, recommended past a few guilds

Athena targets Node 18+. Types come from discord-api-types/v10 and are re-exported, so you rarely import that package directly.

Two ways to build

Plain Client gives you the gateway, REST helpers, and the cache. You wire events yourself.

import { Client, GatewayIntentBits } from 'athena';
 
const client = new Client(`Bot ${process.env.DISCORD_TOKEN}`, {
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
 
client.on('ready', () => console.log(`Up as ${client.user.username}`));
client.on('messageCreate', (m) => {
  if (m.content === '!ping') void client.createMessage(m.channel.id, 'Pong!');
});
client.on('error', console.error);
 
void client.connect();

CommandClient extends Client and adds slash command registration, deployment, dispatch, cooldowns, and middleware. Most bots want this. See Commands framework.

The token

The first argument is the token and it must include the Bot prefix. Athena uses the prefix to detect a bot account.

new Client(`Bot ${process.env.DISCORD_TOKEN}`, options);

Connecting and readiness

connect() opens the gateway. The ready event fires once after every shard has finished its initial GUILD_CREATE burst. Do startup work (such as deploying commands) in ready.

Always handle error

Athena extends an EventEmitter. An unhandled error event throws. Attach a listener even if you only log it.

Where next