erlc-api 1.3.8 → 1.3.9

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.
@@ -0,0 +1,27 @@
1
+ name: Publish Node.js Package
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ publish-npm:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Set up Node.js
16
+ uses: actions/setup-node@v3
17
+ with:
18
+ node-version: 20
19
+ registry-url: https://registry.npmjs.org/
20
+
21
+ - name: Install dependencies
22
+ run: npm ci
23
+
24
+ - name: Publish package to NPM
25
+ run: npm publish
26
+ env:
27
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
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,107 +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 getPlayersFunc = 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
- ```
92
-
93
- ### [Discord Bot](https://discord.com/oauth2/authorize?client_id=1014990793280323624)
94
-
95
- The Discord Bot Back Online 29/05/2024
96
-
97
- ## [Module Examples](https://scarlet-2.gitbook.io/erlc-api/)
98
-
99
- ### [PRC API Docs](https://apidocs.policeroleplay.community/reference/api-reference)
100
-
101
- ### Credits
102
-
103
- Library Re-Development - [Egologics](https://twitter.com/0Adexus0)
104
-
105
- API Development - [Police Roleplay Community](https://twitter.com/PRC_Roblox)
106
-
107
- 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,6 +1,6 @@
1
1
  {
2
2
  "name": "erlc-api",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "An ER:LC API wrapper for JS/TS",
5
5
  "main": "index.js",
6
6
  "types": "src/types/index.d.ts",
@@ -8,7 +8,8 @@
8
8
  "erlc",
9
9
  "roblox",
10
10
  "prc",
11
- "erlc api"
11
+ "erlc-api",
12
+ "liberty-county"
12
13
  ],
13
14
  "author": "egologics",
14
15
  "license": "MIT",
@@ -1,36 +1,36 @@
1
- const erlc = require('../erlc.js')
2
- const assert = require('../functions/assert.js')
3
-
4
- /**
5
- * @typedef {Object} ClientConfig
6
- * @property {string} globalToken - Your ER:LC global API token
7
- */
8
-
9
- /**
10
- * Creates an authorised ER:LC client for requests
11
- * @class
12
- * @param {ClientConfig} options - Client Options
13
- */
14
-
15
- class Client {
16
-
17
- /**
18
- * @constructor
19
- * @param {ClientConfig} options - Client Options
20
- */
21
- constructor(options) {
22
- assert(typeof options === 'object', `Syntax error: object expected for "options", received ${typeof options}`);
23
- this.options = { ...options };
24
- }
25
-
26
- /**
27
- * Updates and returns the client configurationg
28
- * @returns {ClientConfig} The client configuration.
29
- */
30
- config() {
31
- erlc.config = this.options
32
- return erlc.config
33
- }
34
- }
35
-
1
+ const erlc = require('../erlc.js')
2
+ const assert = require('../functions/assert.js')
3
+
4
+ /**
5
+ * @typedef {Object} ClientConfig
6
+ * @property {string} globalToken - Your ER:LC global API token
7
+ */
8
+
9
+ /**
10
+ * Creates an authorised ER:LC client for requests
11
+ * @class
12
+ * @param {ClientConfig} options - Client Options
13
+ */
14
+
15
+ class Client {
16
+
17
+ /**
18
+ * @constructor
19
+ * @param {ClientConfig} options - Client Options
20
+ */
21
+ constructor(options) {
22
+ assert(typeof options === 'object', `Syntax error: object expected for "options", received ${typeof options}`);
23
+ this.options = { ...options };
24
+ }
25
+
26
+ /**
27
+ * Updates and returns the client configurationg
28
+ * @returns {ClientConfig} The client configuration.
29
+ */
30
+ config() {
31
+ erlc.config = this.options
32
+ return erlc.config
33
+ }
34
+ }
35
+
36
36
  module.exports = Client
package/src/constants.js CHANGED
@@ -1,2 +1,2 @@
1
- exports.Vanity = "https://policeroleplay.community/join?code="
1
+ exports.Vanity = "https://policeroleplay.community/join?code="
2
2
  exports.BASEURL = "https://api.policeroleplay.community/v1"
package/src/erlc.js CHANGED
@@ -1,13 +1,13 @@
1
- exports.config = {}
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')
12
-
1
+ exports.config = {}
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')
12
+
13
13
  exports.Client = require('./classes/client.js')
@@ -1,5 +1,5 @@
1
- module.exports = function(condition, message) {
2
- if (!condition) {
3
- throw new Error(message);
4
- }
1
+ module.exports = function(condition, message) {
2
+ if (!condition) {
3
+ throw new Error(message);
4
+ }
5
5
  }
@@ -1,28 +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/bans`, {
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
- });
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/bans`, {
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
28
  };
@@ -1,28 +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/commandlogs`, {
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
- });
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/commandlogs`, {
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
28
  };
@@ -1,28 +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/joinlogs`, {
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
- });
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/joinlogs`, {
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
28
  };
@@ -1,28 +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/killlogs`, {
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
- });
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/killlogs`, {
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
28
  };
@@ -1,28 +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/modcalls`, {
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
- });
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/modcalls`, {
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
28
  };
@@ -1,28 +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/players`, {
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
- });
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/players`, {
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
28
  };
@@ -1,28 +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/queue`, {
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
- });
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/queue`, {
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
28
  };
@@ -1,52 +1,52 @@
1
- const { BASEURL , Vanity} = require("../../constants.js");
2
- module.exports = (serverToken) => {
3
- return new Promise(async (resolve, reject) => {
4
- try {
5
- const fetch = await import("node-fetch");
6
- const { config } = await import("../../erlc.js");
7
-
8
- const res = await fetch.default(`${BASEURL}/server`, {
9
- headers: {
10
- "Authorization": config?.globalToken,
11
- "Server-Key": serverToken,
12
- },
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
- const getUsername = async (userId) => {
23
- const response = await fetch.default(`https://users.roblox.com/v1/users/${userId}`);
24
- const userData = await response.json();
25
- if (!response.ok) {
26
- throw new Error(`Error fetching username for ID: ${userId}`);
27
- }
28
- return userData.name;
29
- };
30
- try {
31
- const ownerUsername = await getUsername(data.OwnerId);
32
- const coOwnerUsernames = await Promise.all(data.CoOwnerIds.map(getUsername));
33
- const VanityURL = `${Vanity}${data.JoinKey}`
34
-
35
-
36
- data.OwnerUsername = ownerUsername;
37
- data.CoOwnerUsernames = coOwnerUsernames;
38
- data.VanityURL = VanityURL
39
-
40
- delete data.OwnerId;
41
- delete data.CoOwnerIds;
42
-
43
- resolve(data);
44
- } catch (error) {
45
- reject(error);
46
- }
47
-
48
- } catch (error) {
49
- reject(error);
50
- }
51
- });
1
+ const { BASEURL , Vanity} = require("../../constants.js");
2
+ module.exports = (serverToken) => {
3
+ return new Promise(async (resolve, reject) => {
4
+ try {
5
+ const fetch = await import("node-fetch");
6
+ const { config } = await import("../../erlc.js");
7
+
8
+ const res = await fetch.default(`${BASEURL}/server`, {
9
+ headers: {
10
+ "Authorization": config?.globalToken,
11
+ "Server-Key": serverToken,
12
+ },
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
+ const getUsername = async (userId) => {
23
+ const response = await fetch.default(`https://users.roblox.com/v1/users/${userId}`);
24
+ const userData = await response.json();
25
+ if (!response.ok) {
26
+ throw new Error(`Error fetching username for ID: ${userId}`);
27
+ }
28
+ return userData.name;
29
+ };
30
+ try {
31
+ const ownerUsername = await getUsername(data.OwnerId);
32
+ const coOwnerUsernames = await Promise.all(data.CoOwnerIds.map(getUsername));
33
+ const VanityURL = `${Vanity}${data.JoinKey}`
34
+
35
+
36
+ data.OwnerUsername = ownerUsername;
37
+ data.CoOwnerUsernames = coOwnerUsernames;
38
+ data.VanityURL = VanityURL
39
+
40
+ delete data.OwnerId;
41
+ delete data.CoOwnerIds;
42
+
43
+ resolve(data);
44
+ } catch (error) {
45
+ reject(error);
46
+ }
47
+
48
+ } catch (error) {
49
+ reject(error);
50
+ }
51
+ });
52
52
  };
@@ -1,28 +1,27 @@
1
- const { BASEURL } = require("../../constants.js");
2
-
3
- module.exports = (serverToken, command) => {
4
- return new Promise(async (resolve, reject) => {
5
- try {
6
- const fetch = await import("node-fetch");
7
- const { config } = await import("../../erlc.js");
8
- const params = JSON.stringify({command: `${command}`})
9
- console.log(params)
10
- const res = await fetch.default(`${BASEURL}/server/command`, {
11
- headers: {
12
- "Authorization": config?.globalToken,
13
- "Server-Key": serverToken,
14
- "Content-Type": "application/json"
15
- },
16
- method: "POST",
17
- body: params
18
- });
19
- if (!res.ok) {
20
- return reject(data);
21
- }
22
-
23
- resolve(true);
24
- } catch (error) {
25
- reject(error);
26
- }
27
- });
28
- };
1
+ const { BASEURL } = require("../../constants.js");
2
+
3
+ module.exports = (serverToken, command) => {
4
+ return new Promise(async (resolve, reject) => {
5
+ try {
6
+ const fetch = await import("node-fetch");
7
+ const { config } = await import("../../erlc.js");
8
+ const params = JSON.stringify({ command: `${command}` });
9
+ const res = await fetch.default(`${BASEURL}/server/command`, {
10
+ headers: {
11
+ Authorization: config?.globalToken,
12
+ "Server-Key": serverToken,
13
+ "Content-Type": "application/json",
14
+ },
15
+ method: "POST",
16
+ body: params,
17
+ });
18
+ if (!res.ok) {
19
+ return reject(data);
20
+ }
21
+
22
+ resolve(true);
23
+ } catch (error) {
24
+ reject(error);
25
+ }
26
+ });
27
+ };
@@ -1,5 +1,5 @@
1
- declare module 'NodeModule' {
2
- interface NodeModule {
3
- type?: string;
4
- }
1
+ declare module 'NodeModule' {
2
+ interface NodeModule {
3
+ type?: string;
4
+ }
5
5
  }
@@ -1,81 +1,81 @@
1
- declare module "erlc-api" {
2
- export interface ClientConfig {
3
- globalToken: string; // The ER:LC global API token
4
- }
5
-
6
- export const BASEURL = "https://api.policeroleplay.community/v1";
7
-
8
- type PlayerId = string;
9
- type PlayerName = string;
10
-
11
- export type ErlcPlayer = `${PlayerName}:${PlayerId}`; // Playername:UserID
12
- export type ErlcPlayerPermission =
13
- | "Normal"
14
- | "Server Administrator"
15
- | "Server Owner"
16
- | "Server Moderator";
17
-
18
- export interface ServerStatus {
19
- Name: string; // The server name
20
- OwnerId: number; // The roblox id of the server owner
21
- CoOwnerIds: number[]; // The roblox ids of the server co owners
22
- CurrentPlayers: number; // The amount of people currently in-game
23
- MaxPlayers: number; // The amount of people who can join the server including server owner
24
- JoinKey: string; // The code used to join the private server
25
- AccVerifiedReq: "Disabled" | "Email" | "Phone/ID"; // The level of verification roblox accounts need to join the private server
26
- TeamBalance: boolean; // If team balance is enabled or not
27
- }
28
-
29
- export interface ServerPlayer {
30
- Player: ErlcPlayer;
31
- Permission: ErlcPlayerPermission;
32
- }
33
-
34
- export interface JoinLog {
35
- Join: boolean; // True is join and False is leave
36
- Timestamp: number; // Timestamp in seconds
37
- Player: ErlcPlayer;
38
- }
39
-
40
- export interface KillLog {
41
- Killed: ErlcPlayer;
42
- Timestamp: number; // Timestamp in seconds
43
- Killer: ErlcPlayer;
44
- }
45
-
46
- export interface CommandLog {
47
- Player: ErlcPlayer;
48
- Timestamp: number; // Timestamp in seconds
49
- Command: string;
50
- }
51
-
52
- export interface ModcallLog {
53
- Caller: ErlcPlayer;
54
- Moderator?: ErlcPlayer; // If call is unanswered property is undefined
55
- Timestamp: number; // Timestamp in seconds
56
- }
57
-
58
- export type ServerBan = Record<PlayerId, PlayerName>;
59
-
60
- export interface VSMCommandBody {
61
- command: string; // ":h Hey everyone!"
62
- }
63
-
64
- export function getBans(serverToken: string): Promise<ServerBan>;
65
- export function getCommandLogs(serverToken: string): Promise<CommandLog[]>;
66
- export function getJoinLogs(serverToken: string): Promise<JoinLog[]>;
67
- export function getKillLogs(serverToken: string): Promise<KillLog[]>;
68
- export function getModcallLogs(serverToken: string): Promise<ModcallLog[]>;
69
- export function getPlayers(serverToken: string): Promise<ServerPlayer[]>;
70
- export function getQueue(serverToken: string): Promise<number[]>;
71
- export function getServer(serverToken: string): Promise<ServerStatus>;
72
- export function runCommand(
73
- serverToken: string,
74
- command: string
75
- ): Promise<boolean>;
76
-
77
- export class Client {
78
- constructor(options: ClientConfig);
79
- config(): ClientConfig;
80
- }
81
- }
1
+ declare module "erlc-api" {
2
+ export interface ClientConfig {
3
+ globalToken: string; // The ER:LC global API token
4
+ }
5
+
6
+ export const BASEURL = "https://api.policeroleplay.community/v1";
7
+
8
+ type PlayerId = string;
9
+ type PlayerName = string;
10
+
11
+ export type ErlcPlayer = `${PlayerName}:${PlayerId}`; // Playername:UserID
12
+ export type ErlcPlayerPermission =
13
+ | "Normal"
14
+ | "Server Administrator"
15
+ | "Server Owner"
16
+ | "Server Moderator";
17
+
18
+ export interface ServerStatus {
19
+ Name: string; // The server name
20
+ OwnerId: number; // The roblox id of the server owner
21
+ CoOwnerIds: number[]; // The roblox ids of the server co owners
22
+ CurrentPlayers: number; // The amount of people currently in-game
23
+ MaxPlayers: number; // The amount of people who can join the server including server owner
24
+ JoinKey: string; // The code used to join the private server
25
+ AccVerifiedReq: "Disabled" | "Email" | "Phone/ID"; // The level of verification roblox accounts need to join the private server
26
+ TeamBalance: boolean; // If team balance is enabled or not
27
+ }
28
+
29
+ export interface ServerPlayer {
30
+ Player: ErlcPlayer;
31
+ Permission: ErlcPlayerPermission;
32
+ }
33
+
34
+ export interface JoinLog {
35
+ Join: boolean; // True is join and False is leave
36
+ Timestamp: number; // Timestamp in seconds
37
+ Player: ErlcPlayer;
38
+ }
39
+
40
+ export interface KillLog {
41
+ Killed: ErlcPlayer;
42
+ Timestamp: number; // Timestamp in seconds
43
+ Killer: ErlcPlayer;
44
+ }
45
+
46
+ export interface CommandLog {
47
+ Player: ErlcPlayer;
48
+ Timestamp: number; // Timestamp in seconds
49
+ Command: string;
50
+ }
51
+
52
+ export interface ModcallLog {
53
+ Caller: ErlcPlayer;
54
+ Moderator?: ErlcPlayer; // If call is unanswered property is undefined
55
+ Timestamp: number; // Timestamp in seconds
56
+ }
57
+
58
+ export type ServerBan = Record<PlayerId, PlayerName>;
59
+
60
+ export interface VSMCommandBody {
61
+ command: string; // ":h Hey everyone!"
62
+ }
63
+
64
+ export function getBans(serverToken: string): Promise<ServerBan>;
65
+ export function getCommandLogs(serverToken: string): Promise<CommandLog[]>;
66
+ export function getJoinLogs(serverToken: string): Promise<JoinLog[]>;
67
+ export function getKillLogs(serverToken: string): Promise<KillLog[]>;
68
+ export function getModcallLogs(serverToken: string): Promise<ModcallLog[]>;
69
+ export function getPlayers(serverToken: string): Promise<ServerPlayer[]>;
70
+ export function getQueue(serverToken: string): Promise<number[]>;
71
+ export function getServer(serverToken: string): Promise<ServerStatus>;
72
+ export function runCommand(
73
+ serverToken: string,
74
+ command: string
75
+ ): Promise<boolean>;
76
+
77
+ export class Client {
78
+ constructor(options: ClientConfig);
79
+ config(): ClientConfig;
80
+ }
81
+ }