erlc-api 1.3.10 → 1.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitattributes CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 0Adexus0
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 0Adexus0
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,110 +1,110 @@
1
- # ER:LC API Wrapper
2
-
3
- A lightweight API Wrapper with 100% coverage of the ER:LC API. Fixed Error and Improvements
4
- 7
5
-
6
- ## Getting Started
7
-
8
- First you need to install the package.
9
-
10
- `npm i erlc-api`
11
-
12
- ### Setting Up
13
-
14
- Setting up is super simple:
15
-
16
- ```js
17
- // index.js
18
- const erlc = require("erlc");
19
- const client = new erlc.Client({
20
- globalToken: "", // You get the global key directly from the ERLC developers. To increase your API request limits
21
- });
22
- client.config(); // Registers your client
23
- ```
24
-
25
- Now you can start using API Methods - here are a few examples:
26
-
27
- ```js
28
- // GetServerInfo.js
29
- const erlc = require("erlc-api"); //JS
30
- import erlc from "erlc-api"; // Module or typeScript
31
-
32
- const getServerFunc = async () => {
33
- const serverId = ""; // The server ApiKey you wish to target. You can get this api key in your (Server Settings)
34
- const server = await erlc.getServer(serverId).catch(console.log); // Gets the server, logs any errors
35
- console.log(server); // Logs the server object
36
-
37
- // Expected Response:
38
- // {
39
- // Name: "Your Sever Name",
40
- // CurrentPlayers: 0,
41
- // MaxPlayers: 40,
42
- // JoinKey: "Your Code Join",
43
- // AccVerifiedReq: "Disabled" | "Email" | "Phone/ID",
44
- // TeamBalance: true or false ,
45
- // OwnerUsername: "Your Name",
46
- // CoOwnerUsernames: [],
47
- // VanityURL: "https://policeroleplay.community/join?code=YourCode",
48
- // },
49
- };
50
-
51
- getServerFunc();
52
- ```
53
-
54
- ```js
55
- // GetPlayers.js
56
- const erlc = require("erlc-api"); //JS
57
- import erlc from "erlc-api"; // Module or typeScript
58
-
59
- const getPlayersFunc = async () => {
60
- const serverId = ""; // The server ApiKey you wish to target. You can get this api key in your (Server Settings)
61
- const server = await erlc.getPlayers(serverId).catch(console.log); // Gets the server, logs any errors
62
- console.log(server); // Logs the server object
63
- // Expected Response:
64
- // [
65
- // {
66
- // "Permission": "Server Owner" Or Member, Moderator,
67
- // "Player": "Player-Username and ID" ,
68
- // "Team": "Civilian" Or Fire, Police, Sherift
69
- // }
70
- // ]
71
- };
72
- getPlayersFunc();
73
- ```
74
-
75
- ```js
76
- //getmodCalls.js
77
- const erlc = require("erlc-api"); //JS
78
- import erlc from "erlc-api"; // Module or typeScript
79
-
80
- const getModCallsFunc = async () => {
81
- const serverId = ""; // The server ApiKey you wish to target. You can get this api key in your (Server Settings)
82
- const server = await erlc.getModcallLogs(serverId).catch(console.log); // Gets the server, logs any errors
83
- console.log(server); // Logs the server object
84
- // Expected Response:
85
- // {
86
- // Caller: ErlcPlayer;
87
- // Moderator?: ErlcPlayer; // If call is unanswered property is undefined
88
- // Timestamp: number;
89
- // }
90
- };
91
- getModCallsFunc()
92
- ```
93
-
94
- ### [Discord Bot](https://discord.com/oauth2/authorize?client_id=1014990793280323624)
95
-
96
- The Discord Bot Back Online 29/05/2024
97
-
98
- ## [Module Examples](https://scarlet-2.gitbook.io/erlc-api/)
99
-
100
- ### [PRC API Docs](https://apidocs.policeroleplay.community/reference/api-reference)
101
-
102
- ## [Liveries]("https://github.com/Exodo0/ERLC-API/tree/main/Custom%20Liveries")
103
-
104
- ### Credits
105
-
106
- Library Re-Development - [Egologics](https://twitter.com/0Adexus0)
107
-
108
- API Development - [Police Roleplay Community](https://twitter.com/PRC_Roblox)
109
-
110
- Apply for more API request limits - [Discord](https://discord.gg/prc)
1
+ # ER:LC API Wrapper
2
+
3
+ A lightweight API Wrapper with 100% coverage of the ER:LC API. Fixed Error and Improvements
4
+ 7
5
+
6
+ ## Getting Started
7
+
8
+ First you need to install the package.
9
+
10
+ `npm i erlc-api`
11
+
12
+ ### Setting Up
13
+
14
+ Setting up is super simple:
15
+
16
+ ```js
17
+ // index.js
18
+ const erlc = require("erlc");
19
+ const client = new erlc.Client({
20
+ globalToken: "", // You get the global key directly from the ERLC developers. To increase your API request limits
21
+ });
22
+ client.config(); // Registers your client
23
+ ```
24
+
25
+ Now you can start using API Methods - here are a few examples:
26
+
27
+ ```js
28
+ // GetServerInfo.js
29
+ const erlc = require("erlc-api"); //JS
30
+ import erlc from "erlc-api"; // Module or typeScript
31
+
32
+ const getServerFunc = async () => {
33
+ const serverId = ""; // The server ApiKey you wish to target. You can get this api key in your (Server Settings)
34
+ const server = await erlc.getServer(serverId).catch(console.log); // Gets the server, logs any errors
35
+ console.log(server); // Logs the server object
36
+
37
+ // Expected Response:
38
+ // {
39
+ // Name: "Your Sever Name",
40
+ // CurrentPlayers: 0,
41
+ // MaxPlayers: 40,
42
+ // JoinKey: "Your Code Join",
43
+ // AccVerifiedReq: "Disabled" | "Email" | "Phone/ID",
44
+ // TeamBalance: true or false ,
45
+ // OwnerUsername: "Your Name",
46
+ // CoOwnerUsernames: [],
47
+ // VanityURL: "https://policeroleplay.community/join?code=YourCode",
48
+ // },
49
+ };
50
+
51
+ getServerFunc();
52
+ ```
53
+
54
+ ```js
55
+ // GetPlayers.js
56
+ const erlc = require("erlc-api"); //JS
57
+ import erlc from "erlc-api"; // Module or typeScript
58
+
59
+ const getPlayersFunc = async () => {
60
+ const serverId = ""; // The server ApiKey you wish to target. You can get this api key in your (Server Settings)
61
+ const server = await erlc.getPlayers(serverId).catch(console.log); // Gets the server, logs any errors
62
+ console.log(server); // Logs the server object
63
+ // Expected Response:
64
+ // [
65
+ // {
66
+ // "Permission": "Server Owner" Or Member, Moderator,
67
+ // "Player": "Player-Username and ID" ,
68
+ // "Team": "Civilian" Or Fire, Police, Sherift
69
+ // }
70
+ // ]
71
+ };
72
+ getPlayersFunc();
73
+ ```
74
+
75
+ ```js
76
+ //getmodCalls.js
77
+ const erlc = require("erlc-api"); //JS
78
+ import erlc from "erlc-api"; // Module or typeScript
79
+
80
+ const getModCallsFunc = async () => {
81
+ const serverId = ""; // The server ApiKey you wish to target. You can get this api key in your (Server Settings)
82
+ const server = await erlc.getModcallLogs(serverId).catch(console.log); // Gets the server, logs any errors
83
+ console.log(server); // Logs the server object
84
+ // Expected Response:
85
+ // {
86
+ // Caller: ErlcPlayer;
87
+ // Moderator?: ErlcPlayer; // If call is unanswered property is undefined
88
+ // Timestamp: number;
89
+ // }
90
+ };
91
+ getModCallsFunc()
92
+ ```
93
+
94
+ ### [Discord Bot](https://discord.com/oauth2/authorize?client_id=1014990793280323624)
95
+
96
+ The Discord Bot Back Online 29/05/2024
97
+
98
+ ## [Module Examples](https://scarlet-2.gitbook.io/erlc-api/)
99
+
100
+ ### [PRC API Docs](https://apidocs.policeroleplay.community/reference/api-reference)
101
+
102
+ ## [Liveries]("https://github.com/Exodo0/ERLC-API/tree/main/Custom%20Liveries")
103
+
104
+ ### Credits
105
+
106
+ Library Re-Development - [Egologics](https://twitter.com/0Adexus0)
107
+
108
+ API Development - [Police Roleplay Community](https://twitter.com/PRC_Roblox)
109
+
110
+ Apply for more API request limits - [Discord](https://discord.gg/prc)
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
- {
2
- "name": "erlc-api",
3
- "version": "1.3.10",
4
- "description": "An ER:LC API wrapper for JS/TS",
5
- "main": "index.js",
6
- "types": "src/types/index.d.ts",
7
- "keywords": [
8
- "erlc",
9
- "roblox",
10
- "prc",
11
- "erlc-api",
12
- "liberty-county"
13
- ],
14
- "author": "egologics",
15
- "license": "MIT",
16
- "devDependencies": {
17
- "typescript": "^5.3.2"
18
- },
19
- "dependencies": {
20
- "node-fetch": "^3.3.2"
21
- },
22
- "scripts": {
23
- "test": "echo \"Error: no test specified\" && exit 1"
24
- },
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/Exodo0/ERLC-API.git"
28
- },
29
- "bugs": {
30
- "url": "https://github.com/Exodo0/ERLC-API/issues"
31
- },
32
- "homepage": "https://github.com/Exodo0/ERLC-API#readme"
33
- }
1
+ {
2
+ "name": "erlc-api",
3
+ "version": "1.3.12",
4
+ "description": "An ER:LC API wrapper for JS/TS",
5
+ "main": "index.js",
6
+ "types": "src/types/index.d.ts",
7
+ "keywords": [
8
+ "erlc",
9
+ "roblox",
10
+ "prc",
11
+ "erlc-api",
12
+ "liberty-county"
13
+ ],
14
+ "author": "egologics",
15
+ "license": "MIT",
16
+ "devDependencies": {
17
+ "typescript": "^5.3.2"
18
+ },
19
+ "dependencies": {
20
+ "node-fetch": "^3.3.2"
21
+ },
22
+ "scripts": {
23
+ "test": "echo \"Error: no test specified\" && exit 1"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/Exodo0/ERLC-API.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/Exodo0/ERLC-API/issues"
31
+ },
32
+ "homepage": "https://github.com/Exodo0/ERLC-API#readme"
33
+ }
package/src/erlc.js CHANGED
@@ -1,13 +1,14 @@
1
- exports.config = {}
1
+ exports.config = {};
2
2
 
3
- exports.getBans = require('./functions/server/getBans.js')
4
- exports.getCommandLogs = require('./functions/server/getCommandLogs.js')
5
- exports.getJoinLogs = require('./functions/server/getJoinLogs.js')
6
- exports.getKillLogs = require('./functions/server/getKillLogs.js')
7
- exports.getModcallLogs = require('./functions/server/getModcallLogs.js')
8
- exports.getPlayers = require('./functions/server/getPlayers.js')
9
- exports.getServer = require('./functions/server/getServer.js')
10
- exports.getQueue = require('./functions/server/getQueue.js')
11
- exports.runCommand = require('./functions/server/runCommand.js')
3
+ exports.getBans = require("./functions/server/getBans.js");
4
+ exports.getCommandLogs = require("./functions/server/getCommandLogs.js");
5
+ exports.getJoinLogs = require("./functions/server/getJoinLogs.js");
6
+ exports.getKillLogs = require("./functions/server/getKillLogs.js");
7
+ exports.getModcallLogs = require("./functions/server/getModcallLogs.js");
8
+ exports.getPlayers = require("./functions/server/getPlayers.js");
9
+ exports.getServer = require("./functions/server/getServer.js");
10
+ exports.getQueue = require("./functions/server/getQueue.js");
11
+ exports.runCommand = require("./functions/server/runCommand.js");
12
+ exports.getVehicles = require("./functions/server/getVehicles.js");
12
13
 
13
- exports.Client = require('./classes/client.js')
14
+ exports.Client = require("./classes/client.js");
@@ -0,0 +1,28 @@
1
+ const { BASEURL } = require("../../constants.js");
2
+
3
+ module.exports = (serverToken) => {
4
+ return new Promise(async (resolve, reject) => {
5
+ try {
6
+ const fetch = await import("node-fetch");
7
+ const { config } = await import("../../erlc.js");
8
+
9
+ const res = await fetch.default(`${BASEURL}/server/vehicles`, {
10
+ headers: {
11
+ Authorization: config?.globalToken,
12
+ "Server-Key": serverToken,
13
+ },
14
+ });
15
+ const data = await res.json().catch((err) => {
16
+ return reject(err);
17
+ });
18
+
19
+ if (!res.ok) {
20
+ return reject(data);
21
+ }
22
+
23
+ resolve(data);
24
+ } catch (error) {
25
+ reject(error);
26
+ }
27
+ });
28
+ };
@@ -15,8 +15,10 @@ module.exports = (serverToken, command) => {
15
15
  method: "POST",
16
16
  body: params,
17
17
  });
18
+
18
19
  if (!res.ok) {
19
- return reject(data);
20
+ const errorData = await res.json();
21
+ return reject(errorData);
20
22
  }
21
23
 
22
24
  resolve(true);
@@ -7,6 +7,8 @@ declare module "erlc-api" {
7
7
 
8
8
  type PlayerId = string;
9
9
  type PlayerName = string;
10
+ type TextureName = string;
11
+ type CarName = string;
10
12
 
11
13
  export type ErlcPlayer = `${PlayerName}:${PlayerId}`; // Playername:UserID
12
14
  export type ErlcPlayerPermission =
@@ -57,10 +59,17 @@ declare module "erlc-api" {
57
59
 
58
60
  export type ServerBan = Record<PlayerId, PlayerName>;
59
61
 
62
+ export interface VehiclesLog {
63
+ Texture: string | null;
64
+ Name: string;
65
+ Owner: ErlcPlayer;
66
+ }
67
+
60
68
  export interface VSMCommandBody {
61
69
  command: string; // ":h Hey everyone!"
62
70
  }
63
71
 
72
+
64
73
  export function getBans(serverToken: string): Promise<ServerBan>;
65
74
  export function getCommandLogs(serverToken: string): Promise<CommandLog[]>;
66
75
  export function getJoinLogs(serverToken: string): Promise<JoinLog[]>;
@@ -69,6 +78,7 @@ declare module "erlc-api" {
69
78
  export function getPlayers(serverToken: string): Promise<ServerPlayer[]>;
70
79
  export function getQueue(serverToken: string): Promise<number[]>;
71
80
  export function getServer(serverToken: string): Promise<ServerStatus>;
81
+ export function getVehicles(serverToken: string): Promise<VehiclesLog[]>;
72
82
  export function runCommand(
73
83
  serverToken: string,
74
84
  command: string