A client for connect to Pokémon Showdown


License
MIT
Install
npm install @dirain/client@0.0.26-dev.1722102421-662f1d1.0

Documentation

@dirain/client

Node.js CI

About

@dirain/client is a very fragile Node.js dual module to you create bots with Pokémon Showdown API.

  • Written in TypeScript
  • Support ESModule & CommonJS
  • Fragile

Instlation

Node.js v16.9.0 or higher required.

npm i @dirain/client

Examle usage

Run npm i @dirain/client before execing file.

Getting all existing battle formats:

const { Client } = require("@dirain/client");

const client = new Client({});
let formats = {};

client.connect();

client.on("ready", () => {
    require("fs").writeFile("./formats.json", JSON.stringify(client.formats, null, 4), (err) => {
        if (err) throw err;
        console.log("Successfuly got a formats data!");
    });
});

Log into registered account:

const { Client } = require("@dirain/client");

const client = new Client({ name: "myAccountName", pass: "thisIsMyRealPassWord", autoJoin: ["botdevelopment"] });

client.connect();

client.on("ready", () => console.log("Logged in as ", client.user.name));

client.on("messageCreate", (message) => {
    if (message.content === "ping") message.reply("Pong!");
});

With TypeScript:

import { Client } from "@dirain/client";

const client = new Client({ name: "My account ~", "NotRealPassL0L", autoJoin: ["botdevelopment"] });

client.connect();

client.on("ready", () => console.log("Logged in as ", client.user!.name);

client.on("messageCreate", (message) => {
    if (message.author.id === client.status.id) return;

    if (message.content === "ping") message.reply("Pong!");
});