JavaScript/TypeScript SDK for Osmium.
| Package | Description |
|---|---|
@osmiumchat/sdk |
WebSocket client |
@osmiumchat/proto |
Generated protobuf types |
npm install @osmiumchat/sdkimport { Client, Events } from "@osmiumchat/sdk";
const client = new Client({ clientId: Number(process.env.CLIENT_ID) });
client.on(Events.Ready, (user) => {
console.log(`Logged in as ${user.name}`);
});
client.on(Events.MessageCreated, async ({ message, author }) => {
if (author?.bot) return;
if (message.message === "!ping") {
const start = Date.now();
const sent = await message.reply("Pong! 🏓");
await sent.edit(`Pong! 🏓 (${Date.now() - start}ms)`);
}
});
client.on(Events.Error, console.error);
client.login(process.env.BOT_TOKEN!);For the full API see @osmiumchat/sdk.
Requires Node 20+ and pnpm.
pnpm install
pnpm build