Code Monkey home page Code Monkey logo

hypixel-api-reborn's Introduction

Hypixel API • Reborn

A feature-rich Hypixel API wrapper for Node.js


Links

Discord Support | Documentation | NPM | GitHub | ToDo | CLI

Requirements

For Node.js users >= v18.18.0
For TypeScript users >= v3.5

Installation & Usage

npm i hypixel-api-reborn
const Hypixel = require('hypixel-api-reborn');
const hypixel = new Hypixel.Client('API-KEY');

// getPlayer
hypixel
  .getPlayer('StavZDev')
  .then((player) => {
    console.log(player.level); // 141
  })
  .catch((e) => {
    console.error(e);
  });

// getGuild
hypixel
  .getGuild('name', 'The Foundation')
  .then((guild) => {
    console.log(guild.level); // 111
  })
  .catch((e) => {
    console.error(e);
  });

For more examples go to our documentation.

Changelog

v11.0.0

Try it now

Code Sandbox

hypixel-api-reborn's People

Contributors

akasgaming avatar alexekinney avatar alvannys avatar brandonhowe avatar bridgesensedev avatar chiefchippy2 avatar dependabot-preview[bot] avatar dependabot[bot] avatar eejit43 avatar gittified avatar itspincha avatar johannes7k75 avatar kathund avatar liamtownsley avatar liamtownsley2 avatar linearaccelerator avatar muchnameless avatar obamafootfungus avatar porterporter avatar qentin1741 avatar richarddorian avatar simonri avatar stavz avatar uncountablemeaning avatar zickles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hypixel-api-reborn's Issues

Skyblock Profiles Returns empty Array

Bug report

  • Part of code where error occurred}
    getSkyblockProfiles
  • What error occurred
    When fetching profiles for b45add7b081443909fb00aa9a3e15eb0 it returns an empty array because they have no profiles. I think it would be better to return an error and not an empty array

Get recentgames

Is there anyway to get a players recent games? if so, how do I do it?

Unprocessable Entity

Bug report

  • Part of code where error occurred - When fetching getPlayer an invalid ign it spits an error saying Unprocessable Entity
  • What error occurred Unprocessable Entity

Typo in TypeScript typings with SkyblockMember.skills.usedAchievementsApi

In TypeScript typings we have a usedAchivementsApi, as shown here:

usedAchievementsApi?: boolean

but actually we are using usedAchivementApi, as shown here:
if (data.player) skillsObject.usedAchievementApi = false;

Instead in the TypeScript typings we should have:

 usedAchievementApi?: boolean 

Inconsistency with timestamp names in SkyblockMember

Timestamp based names aren't consistent, we have:

  • firstJoinTimestamp, firstJoinAt
  • firstJoinHubTimestamp, firstJoinHubAt
  • lastSave (no timestamp), lastSaveAt
  • lastDeathAt, lastDeath (no timestamp, opposite order)

GuildMember#expHistory type is wrong

The current type:

{
    day: string;
    date: Date;
    exp: number;
    totalExp: number;
}[][]

What it was supposed to be:

{
    day: string;
    date: Date;
    exp: number;
    totalExp: number;
}[]

[SUGGESTION] Change code to not throw error when player requested does not exist

I'm trying to make an application using Hypixel-API-Reborn (it's great by the way thank you so much for doing this), but every time a non-existent player is requested using, say, Client.getPlayer(), the Errors.PLAYER_DOES_NOT_EXIST error is thrown. If it just returned no value then a developer could check using a callback function whether the function returned a value then return an error in their app instead of the entire app crashing. This would be incredibly helpful.

TypeError: Hypixel.Bid is not a constructor

Bug report

I don't know if it's my mistake or the api in case it's mine the mistake plus examples would help

  • Error:
TypeError: hypixel_api_reborn_1.Bid is not a constructor
   at Object.<anonymous> (C:\Users\minec\Documents\GitHub\Auctions Flipper\index.js:6:11)
   at Module._compile (internal/modules/cjs/loader.js:1063:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
   at Module.load (internal/modules/cjs/loader.js:928:32)
   at Function.Module._load (internal/modules/cjs/loader.js:769:14)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
   at internal/main/run_main_module.js:17:47
npm ERR! code 1
npm ERR! path C:\Users\minec\Documents\GitHub\Auctions Flipper
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "node index.js"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\minec\AppData\Local\npm-cache\_logs\2021-01-20T18_56_07_944Z-debug.log
  • Code:
    Index.ts
import { Bid } from 'hypixel-api-reborn';
//import { API_KEY } from './config.json';
//const hypixel = new Client(API_KEY);

const bid = new Bid({
    amount: 1,
    //at: Date(),
    //timestamp: Date.now()
})

console.log(bid)

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

Typings don't work with VSCode

When I use a property (like Player.nickname) in my project, it shows up as "any" type, despite typings having it as "string" type
Player.nickname screenshot
Typings file screenshot

getMembersByUUIDMap returning incorrect weeklyExperience

Bug report

Code:

hypixel.getGuild('name', 'Socked').then(guild => {
        hypixel.getPlayer(args[0], {guild: true}).then(player => {
        console.log(player.guild.getMemberUUIDMap().get(player.uuid).weeklyExperience)
   })
})

Returns: 0[object Object][object Object][object Object][object Object][object Object][object Object][object Object]

This also produces the same result when checking the whole json. It'll look something like this (me):

GuildMember {
  uuid: 'b40a8d04ce4b499d8aed4359fa4050ec',
  joinedAtTimestamp: undefined,
  joinedAt: Invalid Date,
  questParticipation: 81,
  rank: 'Moderator',
  mutedUntilTimestamp: null,
  mutedUntil: null,
  expHistory: [
    { day: '0', exp: [Object] },
    { day: '1', exp: [Object] },
    { day: '2', exp: [Object] },
    { day: '3', exp: [Object] },
    { day: '4', exp: [Object] },
    { day: '5', exp: [Object] },
    { day: '6', exp: [Object] }
  ],
  weeklyExperience: '0[object Object][object Object][object Object][object Object][object Object][object Object][object Object]'
}

The weeklyExperience returns, again: 0[object Object][object Object][object Object][object Object][object Object][object Object][object Object]

Also, as a side note:

guild.getMemberUUIDMap().get(player.uuid).expHistory[0].exp

Returns [object Object], while

guild.getMemberUUIDMap().get(player.uuid).expHistory[0].exp.exp

Returns the correct value. Naming issue?

getPlayer and getStatus in one message

Hello, Is there anyway to get getPlayer and getStatus in one message? for example, I want to have one message where I can get player version, rank, map, game, mode etc..

getPlayer will fail and thorw an error if user has never played woolwars

Bug report

  • Part of code where error occurred
    Woolwars getting class
  • What error occurred
    TypeError: Cannot read properties of undefined (reading 'selected_class')
    When running getPlayer it will fail if the user has never played woolwars because it cant get there stats. I found this error using stavzdev as a test username/uuid

Return error for some player

Bug report

Get error reading 'catacombs' for some uuid or player nickname but not for all

  • Part of code where error occurred
    hypixel .getSkyblockProfiles('629bcf79-84cd-4866-835c-81838eb40398') .then((profiles) => { console.log(profiles); }) .catch((e) => { console.error(e); // if player doesn't exist will throw an error });
  • What error occurred
    TypeError: Cannot read properties of undefined (reading 'catacombs') at getDungeons (E:\dev\node_modules\hypixel-api-reborn\src\structures\SkyBlock\SkyblockMember.js:351:59) at new SkyblockMember (E:\dev\node_modules\hypixel-api-reborn\src\structures\SkyBlock\SkyblockMember.js:147:21) at E:\dev\node_modules\hypixel-api-reborn\src\structures\SkyBlock\SkyblockProfile.js:25:68 at Array.map (<anonymous>) at new SkyblockProfile (E:\de\node_modules\hypixel-api-reborn\src\structures\SkyBlock\SkyblockProfile.js:25:57) at E:\dev\node_modules\hypixel-api-reborn\src\API\skyblock\getSkyblockProfiles.js:43:30 at Array.map (<anonymous>) at module.exports (E:\de\node_modules\hypixel-api-reborn\src\API\skyblock\getSkyblockProfiles.js:43:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Woolwars tourney stats only bug

Bug report

Part of code where error occurred

When fetching a players stats if they have never played woolwars it should return null but if they have only played woolwars in the tourney they dont have any of the other stats. This causes an error coz the code cant find the required stats to build the response. This is because they only have stats for the tourney in the api response and not all the other stats a normal player would have.

What error occurred

TypeError: Cannot read properties of undefined (reading 'assault')
    at WoolWars.generateStatsFor (/home/kathund/github/hypixel-api-reborn/src/structures/MiniGames/WoolWars.js:86:52)
    at new WoolWars (/home/kathund/github/hypixel-api-reborn/src/structures/MiniGames/WoolWars.js:44:25)
    at new Player (/home/kathund/github/hypixel-api-reborn/src/structures/Player.js:239:44)
    at module.exports (/home/kathund/github/hypixel-api-reborn/src/API/getPlayer.js:21:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async test (/home/kathund/github/hypixel-api-reborn/tests/test.js:30:16)

ESLint Complaining

Bug report

Eslint 8.14.0 says:

Error: Rules with suggestions must set the meta.hasSuggestionsproperty totrue. meta.docs.suggestion is ignored by ESLint. Occurred while linting /home/chiefchippy2/Projects/har-for-real/hypixel-api-reborn/typings/index.d.ts:239 Rule: "@typescript-eslint/no-explicit-any" at Object.report (/home/chiefchippy2/.nvm/versions/node/v18.0.0/lib/node_modules/eslint/lib/linter/linter.js:1094:39) at TSAnyKeyword (/home/chiefchippy2/Projects/har-for-real/hypixel-api-reborn/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-explicit-any.js:183:25) at ruleErrorHandler (/home/chiefchippy2/.nvm/versions/node/v18.0.0/lib/node_modules/eslint/lib/linter/linter.js:1114:28) at /home/chiefchippy2/.nvm/versions/node/v18.0.0/lib/node_modules/eslint/lib/linter/safe-emitter.js:45:58 at Array.forEach (<anonymous>) at Object.emit (/home/chiefchippy2/.nvm/versions/node/v18.0.0/lib/node_modules/eslint/lib/linter/safe-emitter.js:45:38) at NodeEventGenerator.applySelector (/home/chiefchippy2/.nvm/versions/node/v18.0.0/lib/node_modules/eslint/lib/linter/node-event-generator.js:297:26) at NodeEventGenerator.applySelectors (/home/chiefchippy2/.nvm/versions/node/v18.0.0/lib/node_modules/eslint/lib/linter/node-event-generator.js:326:22) at NodeEventGenerator.enterNode (/home/chiefchippy2/.nvm/versions/node/v18.0.0/lib/node_modules/eslint/lib/linter/node-event-generator.js:340:14) at CodePathAnalyzer.enterNode (/home/chiefchippy2/.nvm/versions/node/v18.0.0/lib/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:795:23)

Currently the ESLint version is on 7.32.0 or above, but if you want to upgrade to 8.14.0.... ^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.