Nondeterministic Programming Methodology

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

    1.4.5 • Public • Published

    hilsu-api

    Библиотека для запросов к api.hil.su

    Авторизация

    Для начала, вам нужно получить токен, через который вы будете работать, самый простой способ:

    let data = await HilSuApi.Client.getTokenViaPasswordAuth("login", "pass");
    console.log(data.accessToken);

    После чего можете инициализироавть клиент с использованием этого токена:

    let client = new HilSuApi.Client("token");

    Экономика

    let economy = client.economy;

    Получение баланса

    economy.balance(): Promise<{user:ChatUser,balances:UserBalances}>;
    client.economy.balance().then(data =>{
        console.log(data.user.username + " has "+data.balances.coins + " coins")
    }).catch(err => console.log(err));

    Список изменений баланса

    economy.changes(currency?: "coins"|"gems",limit?: number, offset?: number): Promise<{userId: string, username: string, changes: Change[]}>;
    client.economy.changes("coins",5,0).then(data =>{
        console.log(data.username + " has change "+data.changes[0].source + " at " + data.changes[0].date.toISOString() + " with delta " + data.changes[0].delta)
    }).catch(err => console.log(err));

    Список переводов

    economy.transfers(currency?: "coins",limit?: number, offset?: number): Promise<{userId: string, username: string, transfers: Transfer[]}>;
    client.economy.transfers("coins",5,0).then(data =>{
        console.log(data.username + " has transfer "+data.transfers[0].id + " at " + data.transfers[0].time.toISOString() + " with delta " + data.transfers[0].delta + " to "+data.transfers[0].peerName)
    }).catch(err => console.log(err));

    Количество переводов

    economy.transfersCount(currency?: "coins"): Promise<{userId: string, username: string, count: number}>;
    client.economy.transfersCount("coins").then(data =>{
        console.log(data.username + " has "+data.count+" transfers");
    }).catch(err => console.log(err));

    Количество изменений баланса

    economy.changesCount(currency?: "coins"|"gems"): Promise<{userId: string, username: string, count: number}>;
    client.economy.changesCount("gems").then(data =>{
        console.log(data.username + " has "+data.count+" changes");
    }).catch(err => console.log(err));

    Топ по балансам

    economy.top(currency?: "coins"|"gems", limit?: number): Promise<{users: TopUser[]}>;
    client.economy.top("gems",1).then(data =>{
        console.log(data.users[0].num+") "+data.users[0].user.username+": "+data.users[0].balance);
    }).catch(err => console.log(err));

    Перевод средств

    economy.transfer(target: string, amount: number, description?: string, currency?: "coins"|"gems"): Promise<{currency: string, senderId: string, senderName: string, targetId: string, targetName: string, balance: number}>;
    client.economy.transfer("MailGik",1,"What the fox say?","gems").then(data =>{
        console.log(data.senderName + " send to " + data.targetName + " 1 " + data.currency + " and have now " + data.balance + " " + data.currency);
    }).catch(err => console.log(err));

    Keywords

    none

    Install

    npm i hilsu-api

    DownloadsWeekly Downloads

    1

    Version

    1.4.5

    License

    MIT

    Unpacked Size

    89 kB

    Total Files

    77

    Last publish

    Collaborators

    • redguys