lichessjs
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

LichessJS

A JavaScript library for interacting with the Lichess Bot/Board API

Installation

npm i lichessjs

Example Usage

const Lichess = require("lichessjs");

const client = new Lichess.BotClient();

const currentGames = new Set();

client.on("connected", async () => {
  console.log("Connected to Account - ", client.user.username);
});

client.on("challenge", async (challenge) => {
  const game = await challenge.accept();
  currentGames.add(game);
  game.on("myTurn", () => {
    const possibleMoves = game.possibleMoves;
    const move =
      possibleMoves[Math.floor(Math.random() * possibleMoves.length)];
    game.move(move);
  });
  game.on("end", () => {
    currentGames.delete(game);
  });
});

client.login(process.env.BOT_TOKEN);

Contributing

Feel free to open a new issue/PR to this repo!

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i lichessjs

Weekly Downloads

2

Version

0.2.1

License

MIT

Unpacked Size

20.3 kB

Total Files

19

Last publish

Collaborators

  • dipamsen