dipamsen / LichessJS

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

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

License:MIT License


Languages

Language:JavaScript 100.0%