Skip to content

osmiumchat/sdk-js

Repository files navigation

sdk-js

JavaScript/TypeScript SDK for Osmium.

Packages

Package Description
@osmiumchat/sdk WebSocket client
@osmiumchat/proto Generated protobuf types

Install

npm install @osmiumchat/sdk

Getting started

import { 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.

Contributing

Requires Node 20+ and pnpm.

pnpm install
pnpm build

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors