Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
World of Warships and CHANGE LANG
  • Loading branch information
GardZock authored Feb 23, 2022
2 parents cb6936f + 41c401b commit 1c575b7
Show file tree
Hide file tree
Showing 44 changed files with 678 additions and 127 deletions.
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const warcord = new WarCord('your-app-id')
```

# Useful Links
- Discord Server (In creation)
- Discord Server (canceled)

# Credits

Expand Down Expand Up @@ -43,6 +43,14 @@ const warcord = new WarCord('your-app-id')
- [Tank](#tank-wotb)
- [Getting a tank by ID](#getting-a-tank-by-id-wotb)

> World of WarShips
- [User](#user-wows)
- [Getting user by ID](#searching-a-user-by-id-wows)
- [Searching user by name](#searching-a-user-by-name-wows)
- [Ships](#ship-wows)
- [Getting ships by User ID](#getting-ships-status-by-id-wows)


# World Of Tanks Functions

## User Wot
Expand Down Expand Up @@ -116,8 +124,7 @@ const tank = await warcord.wargaming.blitz.tank.get('ID of Tank')
//this returns an Object with tank data.
```



# World of Tanks Blitz Functions

## User Wotb

Expand Down Expand Up @@ -179,3 +186,29 @@ const clan = await warcord.wargaming.blitz.clan.get(searchingClan[0].clan_id)
const tank = await warcord.wargaming.blitz.tank.get('ID of Tank')
//this returns an Object with tank data.
```
# World-of-Warships

# World of WarShips Functions

## User

### Getting user by ID WOWS
```js
...
const user = await warcord.wargaming.wows.user.get('ID of User')
//this returns user data.
```

### Searching user by name WOWS
```js
...
const user = await warcord.wargaming.wows.user.search('Name of User')
//this returns user ID and Name.
```

### Getting ships status by User ID
```js
...
const ships = await warcord.wargaming.wows.ship.get('ID of User')
//this returns an Array with Ships Status.
```
6 changes: 4 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import { BaseClass } from './builds/class/base';
declare class WarCord extends BaseClass {
app: {
id: string;
lang?: string;
};
wargaming: WargamingBase;
constructor(app_id: string);
private checker;
constructor(app_id: string, lang?: string);
private idChecker;
private langChecker;
}
export { WarCord };
export { WOTClanResolve, WOTClanSearchResolve, WOTTanksResolve, WOTTopTanksResolve, WOTUserResolve, UserSearchResolve };
25 changes: 21 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ exports.WarCord = void 0;
const base_1 = require("./packages/wargaming/build/class/base");
const base_2 = require("./builds/class/base");
class WarCord extends base_2.BaseClass {
constructor(app_id) {
constructor(app_id, lang) {
super(app_id);
this.app = { id: this.checker(app_id) };
this.wargaming = new base_1.WargamingBase(app_id);
this.app = { id: this.idChecker(app_id), lang: this.langChecker(lang) };
this.wargaming = new base_1.WargamingBase(app_id, lang);
}
checker(id) {
idChecker(id) {
if (!id || id.length <= 0) {
console.log('[WarCord] Your API ID is empty. (using Wargaming API)');
return '';
Expand All @@ -18,5 +18,22 @@ class WarCord extends base_2.BaseClass {
return id;
}
}
langChecker(lang) {
if (!lang)
return 'com';
const langs = [
'na',
'eu',
'ru',
'asia'
];
if (!langs.includes(lang)) {
console.log('[WarCord] Your API Lang is not valid. (using Wargaming API)');
return 'com';
}
if (lang = 'na')
lang = 'com';
return lang;
}
}
exports.WarCord = WarCord;
33 changes: 33 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "warcord",
"version": "1.0.0",
"description": "A Simple lib with wargaming API",
"author": "GardZock",
"license": "Apache-2.0",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"dev": "tsnd --respawn --transpile-only tests/tests.ts",
"tscd": "tsc --declaration"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Warcord/WarCord-Lib.git"
},
"bugs": {
"url": "https://github.com/Warcord/WarCord-Lib/issues"
},
"homepage": "https://github.com/Warcord/WarCord-Lib#readme",
"devDependencies": {
"@types/ms": "^0.7.31",
"@types/node": "^17.0.18",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.6.0",
"ts-node-dev": "^1.1.8",
"typescript": "^4.5.4"
},
"dependencies": {
"axios": "^0.24.0"
}
}
15 changes: 12 additions & 3 deletions dist/packages/wargaming/build/class/base.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { WorldOfTanksUser } from '../../world-of-tanks/src/functions/user';
import { BaseClass } from '../../../../builds/class/base';
import { WargamingApp } from '../interfaces/app';
import { WorldOfTanksUser } from '../../world-of-tanks/src/functions/user';
import { WorldOfTanksTank } from '../../world-of-tanks/src/functions/tank';
import { WorldOfTanksClan } from '../../world-of-tanks/src/functions/clan';
import { BaseClass } from '../../../../builds/class/base';
import { WOTBUser } from '../../world-of-tanks-blitz/src/functions/user';
import { WOTBTank } from '../../world-of-tanks-blitz/src/functions/tank';
import { WOTBClan } from '../../world-of-tanks-blitz/src/functions/clan';
import { WOWSUser } from '../../world-of-warships/src/functions/user';
import { WOWSShip } from '../../world-of-warships/src/functions/ship';
import { WOWSClans } from '../../world-of-warships/src/functions/clan';
declare class WargamingBase extends BaseClass implements WargamingApp {
app: {
id: string;
lang?: string;
};
wot: {
user: WorldOfTanksUser;
Expand All @@ -20,6 +24,11 @@ declare class WargamingBase extends BaseClass implements WargamingApp {
tank: WOTBTank;
clan: WOTBClan;
};
constructor(app_id: string);
wows: {
user: WOWSUser;
ship: WOWSShip;
clan: WOWSClans;
};
constructor(app_id: string, lang?: string);
}
export { WargamingBase };
26 changes: 17 additions & 9 deletions dist/packages/wargaming/build/class/base.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WargamingBase = void 0;
const base_1 = require("../../../../builds/class/base");
const user_1 = require("../../world-of-tanks/src/functions/user");
const tank_1 = require("../../world-of-tanks/src/functions/tank");
const clan_1 = require("../../world-of-tanks/src/functions/clan");
const base_1 = require("../../../../builds/class/base");
const user_2 = require("../../world-of-tanks-blitz/src/functions/user");
const tank_2 = require("../../world-of-tanks-blitz/src/functions/tank");
const clan_2 = require("../../world-of-tanks-blitz/src/functions/clan");
const user_3 = require("../../world-of-warships/src/functions/user");
const ship_1 = require("../../world-of-warships/src/functions/ship");
const clan_3 = require("../../world-of-warships/src/functions/clan");
class WargamingBase extends base_1.BaseClass {
constructor(app_id) {
constructor(app_id, lang) {
super(app_id);
this.app = { id: app_id };
this.app = { id: app_id, lang: lang };
this.wot = {
user: new user_1.WorldOfTanksUser(app_id),
tank: new tank_1.WorldOfTanksTank(app_id),
clan: new clan_1.WorldOfTanksClan(app_id)
user: new user_1.WorldOfTanksUser(app_id, lang),
tank: new tank_1.WorldOfTanksTank(app_id, lang),
clan: new clan_1.WorldOfTanksClan(app_id, lang)
};
this.blitz = {
user: new user_2.WOTBUser(app_id),
tank: new tank_2.WOTBTank(app_id),
clan: new clan_2.WOTBClan(app_id)
user: new user_2.WOTBUser(app_id, lang),
tank: new tank_2.WOTBTank(app_id, lang),
clan: new clan_2.WOTBClan(app_id, lang)
};
this.wows = {
user: new user_3.WOWSUser(app_id, lang),
ship: new ship_1.WOWSShip(app_id, lang),
clan: new clan_3.WOWSClans(app_id, lang)
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { WOTBClanResolve } from '../interfaces/clan/clan-resolve';
declare class WOTBClan extends BaseClass {
app: {
id: string;
lang?: string;
};
constructor(app_id: string);
constructor(app_id: string, lang?: string);
get(clanID: string | number): Promise<WOTBClanResolve | null>;
search(clanNameOrTag: string): Promise<any | null>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ exports.WOTBClan = void 0;
const base_1 = require("../../../../../builds/class/base");
const axios_1 = __importDefault(require("axios"));
class WOTBClan extends base_1.BaseClass {
constructor(app_id) {
constructor(app_id, lang) {
super(app_id);
this.app = { id: app_id };
this.app = { id: app_id, lang: lang };
}
get(clanID) {
return __awaiter(this, void 0, void 0, function* () {
let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data;
let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data;
if (data.status == "error")
return null;
return data.data[clanID];
});
}
search(clanNameOrTag) {
return __awaiter(this, void 0, void 0, function* () {
let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data;
let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data;
if (data.status == "error" || data.data.length <= 0)
return null;
return data.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { WOTBTankResolve } from '../interfaces/tank/tank-resolve';
declare class WOTBTank extends BaseClass {
app: {
id: string;
lang?: string;
};
constructor(app_id: string);
constructor(app_id: string, lang?: string);
get(tankID: string | number): Promise<WOTBTankResolve | null>;
}
export { WOTBTank };
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ exports.WOTBTank = void 0;
const base_1 = require("../../../../../builds/class/base");
const axios_1 = __importDefault(require("axios"));
class WOTBTank extends base_1.BaseClass {
constructor(app_id) {
constructor(app_id, lang) {
super(app_id);
this.app = { id: app_id };
this.app = { id: app_id, lang: lang };
}
get(tankID) {
return __awaiter(this, void 0, void 0, function* () {
var data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data;
var data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data;
if (data.status == "error")
return null;
return data.data[tankID];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { WOTBTankTop } from '../interfaces/tank/tank-top';
declare class WOTBUser extends BaseClass {
app: {
id: string;
lang?: string;
};
constructor(app_id: string);
constructor(app_id: string, lang?: string);
get(userID: string | number): Promise<WOTBUserResolve | null>;
search(userName: string): Promise<UserSearchResolve | null>;
topTanks(userID: string | number): Promise<WOTBTankTop | null>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ exports.WOTBUser = void 0;
const base_1 = require("../../../../../builds/class/base");
const axios_1 = __importDefault(require("axios"));
class WOTBUser extends base_1.BaseClass {
constructor(app_id) {
constructor(app_id, lang) {
super(app_id);
this.app = { id: app_id };
this.app = { id: app_id, lang: lang };
}
get(userID) {
return __awaiter(this, void 0, void 0, function* () {
let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/account/info/?application_id=${this.app.id}&account_id=${userID}`)).data;
let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/account/info/?application_id=${this.app.id}&account_id=${userID}`)).data;
if (data.status == "error")
return null;
data = data.data[userID];
Expand All @@ -40,15 +40,15 @@ class WOTBUser extends base_1.BaseClass {
}
search(userName) {
return __awaiter(this, void 0, void 0, function* () {
let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/account/list/?application_id=${this.app.id}&search=${userName}`)).data;
let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/account/list/?application_id=${this.app.id}&search=${userName}`)).data;
if (data.status == "error" || data.data.length <= 0)
return null;
return data.data;
});
}
topTanks(userID) {
return __awaiter(this, void 0, void 0, function* () {
let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/tanks/stats/?application_id=${this.app.id}&account_id=${userID}`)).data;
let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/tanks/stats/?application_id=${this.app.id}&account_id=${userID}`)).data;
if (data.status == "error" || data.data.length <= 0)
return null;
data = data.data[userID];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { BaseClass } from '../../../../../builds/class/base';
declare class WorldOfTanksClan extends BaseClass {
app: {
id: string;
lang?: string;
};
constructor(app_id: string);
constructor(app_id: string, lang?: string);
/**
* Get a clan in World of Tanks.
* @param clanID ID of clan.
Expand Down
10 changes: 5 additions & 5 deletions dist/packages/wargaming/world-of-tanks/src/functions/clan.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ exports.WorldOfTanksClan = void 0;
const axios_1 = __importDefault(require("axios"));
const base_1 = require("../../../../../builds/class/base");
class WorldOfTanksClan extends base_1.BaseClass {
constructor(app_id) {
constructor(app_id, lang) {
super(app_id);
this.app = { id: app_id };
this.app = { id: app_id, lang: lang };
}
/**
* Get a clan in World of Tanks.
Expand All @@ -27,7 +27,7 @@ class WorldOfTanksClan extends base_1.BaseClass {
*/
get(clanID) {
return __awaiter(this, void 0, void 0, function* () {
let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data;
let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data;
if (data.status == "error")
return null;
data = data.data[clanID];
Expand Down Expand Up @@ -63,7 +63,7 @@ class WorldOfTanksClan extends base_1.BaseClass {
*/
search(clanNameOrTag) {
return __awaiter(this, void 0, void 0, function* () {
let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data;
let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data;
if (data.status == "error")
return null;
data = data.data;
Expand All @@ -79,7 +79,7 @@ class WorldOfTanksClan extends base_1.BaseClass {
*/
rating(clanID) {
return __awaiter(this, void 0, void 0, function* () {
let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/clanratings/clans/?application_id=${this.app.id}&clan_id=${clanID}`)).data;
let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/clanratings/clans/?application_id=${this.app.id}&clan_id=${clanID}`)).data;
if (data.status == "error")
return null;
data = data.data[clanID];
Expand Down
Loading

0 comments on commit 1c575b7

Please sign in to comment.