gamerbot-module 1.2.1 → 1.2.3
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/dist/classes/GuildData.d.ts +1 -0
- package/dist/classes/GuildData.js +1 -0
- package/dist/classes/config_data.d.ts +17 -0
- package/dist/classes/config_data.js +41 -0
- package/dist/classes/gamerbot.d.ts +1 -1
- package/dist/classes/gamerbot.js +9 -5
- package/dist/classes/guild_data.d.ts +24 -0
- package/dist/classes/guild_data.js +48 -0
- package/dist/classes/profile_data.d.ts +21 -0
- package/dist/classes/profile_data.js +22 -0
- package/package.json +32 -32
|
@@ -20,6 +20,7 @@ export class GuildData {
|
|
|
20
20
|
this.staffModlogs = json_data.staffModlogs;
|
|
21
21
|
this.sverokMails = json_data.sverokMails;
|
|
22
22
|
this.frameConfig = json_data.frameConfig;
|
|
23
|
+
this.extraObjects = new Map(Object.entries(json_data.extraObjects));
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Saves guild data to database
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class ConfigData {
|
|
2
|
+
id: Number;
|
|
3
|
+
debug: Boolean;
|
|
4
|
+
username: String;
|
|
5
|
+
activity: String;
|
|
6
|
+
activityType: String;
|
|
7
|
+
removeLinks: Boolean;
|
|
8
|
+
xp: Object;
|
|
9
|
+
importantUpdatesChannelId: Object;
|
|
10
|
+
debugGuildID: String;
|
|
11
|
+
json_data: any;
|
|
12
|
+
constructor(json_data: any);
|
|
13
|
+
/**
|
|
14
|
+
* Saves config data to database
|
|
15
|
+
*/
|
|
16
|
+
save(): Promise<unknown>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GamerBotAPI } from "./gamerbot";
|
|
2
|
+
export class ConfigData {
|
|
3
|
+
constructor(json_data) {
|
|
4
|
+
this.json_data = JSON.parse(JSON.stringify(json_data));
|
|
5
|
+
this.id = json_data.id;
|
|
6
|
+
this.debug = json_data.debug;
|
|
7
|
+
this.username = json_data.username;
|
|
8
|
+
this.activity = json_data.activity;
|
|
9
|
+
this.activityType = json_data.activityType;
|
|
10
|
+
this.removeLinks = json_data.removeLinks;
|
|
11
|
+
this.xp = json_data.xp;
|
|
12
|
+
this.importantUpdatesChannelId = json_data.importantUpdatesChannelId;
|
|
13
|
+
this.debugGuildID = json_data.debugGuildID;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Saves config data to database
|
|
17
|
+
*/
|
|
18
|
+
async save() {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
let changed_data = {};
|
|
21
|
+
Object.keys(this).forEach((key) => {
|
|
22
|
+
if (key == "json_data")
|
|
23
|
+
return;
|
|
24
|
+
let value = Object.entries(this).find(([k, v]) => k == key &&
|
|
25
|
+
((!Array.isArray(v)) && !Object.is(v, this.json_data[key]) || (Array.isArray(v) && !GamerBotAPI.arraysEqual(v, this.json_data[key]))));
|
|
26
|
+
if (value)
|
|
27
|
+
changed_data[key] = value[1];
|
|
28
|
+
});
|
|
29
|
+
if (Object.keys(changed_data).length == 0)
|
|
30
|
+
return resolve(changed_data);
|
|
31
|
+
fetch(GamerBotAPI.API_URL + "/api/config/" + this.id, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify(changed_data),
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
'authorization': 'Bearer ' + GamerBotAPI.TOKEN
|
|
37
|
+
}
|
|
38
|
+
}).then((response) => { resolve(response); }).catch((err) => { console.error(err); });
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
package/dist/classes/gamerbot.js
CHANGED
|
@@ -11,9 +11,10 @@ export class GamerBotAPI {
|
|
|
11
11
|
if (dev) {
|
|
12
12
|
GamerBotAPI.API_URL = "http://localhost:3000";
|
|
13
13
|
}
|
|
14
|
-
this.getAPIStatus().then(() => {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
this.getAPIStatus().then((t) => {
|
|
15
|
+
if (t) {
|
|
16
|
+
console.log("API is available");
|
|
17
|
+
}
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
async getAPIStatus() {
|
|
@@ -33,14 +34,17 @@ export class GamerBotAPI {
|
|
|
33
34
|
this.getAPIStatus();
|
|
34
35
|
}, 5000);
|
|
35
36
|
});
|
|
36
|
-
if (data.service == "OK")
|
|
37
|
-
|
|
37
|
+
if (data.service == "OK") {
|
|
38
|
+
this.apiStatus = true;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
38
41
|
else {
|
|
39
42
|
console.error("API is not available, trying to connect to the API again in 5 seconds");
|
|
40
43
|
setTimeout(() => {
|
|
41
44
|
this.getAPIStatus();
|
|
42
45
|
}, 5000);
|
|
43
46
|
}
|
|
47
|
+
return false;
|
|
44
48
|
}
|
|
45
49
|
static arraysEqual(a, b) {
|
|
46
50
|
if (a === b)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare class GuildData {
|
|
2
|
+
guildID: string;
|
|
3
|
+
privateVoiceChannel: string;
|
|
4
|
+
publicVoiceChannel: string;
|
|
5
|
+
infoVoiceChannel: string;
|
|
6
|
+
notificationChannel: string;
|
|
7
|
+
ticketParent: string;
|
|
8
|
+
archivedTicketParent: string;
|
|
9
|
+
allowedLinksChannels: Array<string>;
|
|
10
|
+
trustedLinkRoles: Array<string>;
|
|
11
|
+
noXpChannels: Array<string>;
|
|
12
|
+
whitelistedLinks: Array<object>;
|
|
13
|
+
threedChannels: Array<string>;
|
|
14
|
+
bansTimes: Array<object>;
|
|
15
|
+
topicList: Array<string>;
|
|
16
|
+
staffModlogs: string;
|
|
17
|
+
sverokMails: Array<string>;
|
|
18
|
+
json_data: any;
|
|
19
|
+
constructor(json_data: any);
|
|
20
|
+
/**
|
|
21
|
+
* Saves guild data to database
|
|
22
|
+
*/
|
|
23
|
+
save(): Promise<unknown>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GamerBotAPI } from "./gamerbot";
|
|
2
|
+
export class GuildData {
|
|
3
|
+
constructor(json_data) {
|
|
4
|
+
this.json_data = JSON.parse(JSON.stringify(json_data));
|
|
5
|
+
this.guildID = json_data.guildID;
|
|
6
|
+
this.privateVoiceChannel = json_data.privateVoiceChannel;
|
|
7
|
+
this.publicVoiceChannel = json_data.publicVoiceChannel;
|
|
8
|
+
this.infoVoiceChannel = json_data.infoVoiceChannel;
|
|
9
|
+
this.notificationChannel = json_data.notificationChannel;
|
|
10
|
+
this.ticketParent = json_data.ticketParent;
|
|
11
|
+
this.archivedTicketParent = json_data.archivedTicketParent;
|
|
12
|
+
this.allowedLinksChannels = json_data.allowedLinksChannels;
|
|
13
|
+
this.trustedLinkRoles = json_data.trustedLinkRoles;
|
|
14
|
+
this.noXpChannels = json_data.noXpChannels;
|
|
15
|
+
this.whitelistedLinks = json_data.whitelistedLinks;
|
|
16
|
+
this.threedChannels = json_data.threedChannels;
|
|
17
|
+
this.bansTimes = json_data.bansTimes;
|
|
18
|
+
this.topicList = json_data.topicList;
|
|
19
|
+
this.staffModlogs = json_data.staffModlogs;
|
|
20
|
+
this.sverokMails = json_data.sverokMails;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Saves guild data to database
|
|
24
|
+
*/
|
|
25
|
+
async save() {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
let changed_data = {};
|
|
28
|
+
Object.keys(this).forEach((key) => {
|
|
29
|
+
if (key == "json_data")
|
|
30
|
+
return;
|
|
31
|
+
let value = Object.entries(this).find(([k, v]) => k == key &&
|
|
32
|
+
((!Array.isArray(v)) && !Object.is(v, this.json_data[key]) || (Array.isArray(v) && !GamerBotAPI.arraysEqual(v, this.json_data[key]))));
|
|
33
|
+
if (value)
|
|
34
|
+
changed_data[key] = value[1];
|
|
35
|
+
});
|
|
36
|
+
if (Object.keys(changed_data).length == 0)
|
|
37
|
+
return resolve(changed_data);
|
|
38
|
+
fetch(GamerBotAPI.API_URL + "/api/guild/" + this.guildID, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
body: JSON.stringify(changed_data),
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
'authorization': 'Bearer ' + GamerBotAPI.TOKEN
|
|
44
|
+
}
|
|
45
|
+
}).then((response) => { resolve(response); }).catch((err) => { console.error(err); });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class PorfileData {
|
|
2
|
+
userID: String;
|
|
3
|
+
serverID: String;
|
|
4
|
+
xp: Number;
|
|
5
|
+
lastMessageTimestamp: Number;
|
|
6
|
+
xpTimeoutUntil: Number;
|
|
7
|
+
level: Number;
|
|
8
|
+
reminder: Array<String>;
|
|
9
|
+
colorHexCode: String;
|
|
10
|
+
privateVoiceID: String;
|
|
11
|
+
privateVoiceThreadID: String;
|
|
12
|
+
profileFrame: String;
|
|
13
|
+
hasLeftTicket: Boolean;
|
|
14
|
+
xpboost: Object;
|
|
15
|
+
exclusiveFrames: Array<String>;
|
|
16
|
+
modLogs: Array<Object>;
|
|
17
|
+
minecraftWhiteList: Boolean;
|
|
18
|
+
minecraftUsername: String;
|
|
19
|
+
minecraftUuid: String;
|
|
20
|
+
constructor(json_data: any);
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class PorfileData {
|
|
2
|
+
constructor(json_data) {
|
|
3
|
+
this.userID = json_data.userID;
|
|
4
|
+
this.serverID = json_data.serverID;
|
|
5
|
+
this.xp = json_data.xp;
|
|
6
|
+
this.lastMessageTimestamp = json_data.lastMessageTimestamp;
|
|
7
|
+
this.xpTimeoutUntil = json_data.xpTimeoutUntil;
|
|
8
|
+
this.level = json_data.level;
|
|
9
|
+
this.reminder = json_data.reminder;
|
|
10
|
+
this.colorHexCode = json_data.colorHexCode;
|
|
11
|
+
this.privateVoiceID = json_data.privateVoiceID;
|
|
12
|
+
this.privateVoiceThreadID = json_data.privateVoiceThreadID;
|
|
13
|
+
this.profileFrame = json_data.profileFrame;
|
|
14
|
+
this.hasLeftTicket = json_data.hasLeftTicket;
|
|
15
|
+
this.xpboost = json_data.xpboost;
|
|
16
|
+
this.exclusiveFrames = json_data.exclusiveFrames;
|
|
17
|
+
this.modLogs = json_data.modLogs;
|
|
18
|
+
this.minecraftWhiteList = json_data.minecraftWhiteList;
|
|
19
|
+
this.minecraftUsername = json_data.minecraftUsername;
|
|
20
|
+
this.minecraftUuid = json_data.minecraftUuid;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gamerbot-module",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"files": [
|
|
9
|
-
"/dist"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
-
"link": "tsc -p tsconfig.json && npm link",
|
|
14
|
-
"tsc": "tsc -p tsconfig.json"
|
|
15
|
-
},
|
|
16
|
-
"author": "lukasabbe",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@eslint/js": "^9.10.0",
|
|
20
|
-
"@types/node": "^20.12.13",
|
|
21
|
-
"concurrently": "^8.2.2",
|
|
22
|
-
"eslint": "^9.10.0",
|
|
23
|
-
"globals": "^15.9.0",
|
|
24
|
-
"nodemon": "^3.1.2",
|
|
25
|
-
"ts-node": "^10.9.2",
|
|
26
|
-
"typescript": "^5.4.5",
|
|
27
|
-
"typescript-eslint": "^8.5.0"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"dotenv": "^16.4.5"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "gamerbot-module",
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"link": "tsc -p tsconfig.json && npm link",
|
|
14
|
+
"tsc": "tsc -p tsconfig.json"
|
|
15
|
+
},
|
|
16
|
+
"author": "lukasabbe",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@eslint/js": "^9.10.0",
|
|
20
|
+
"@types/node": "^20.12.13",
|
|
21
|
+
"concurrently": "^8.2.2",
|
|
22
|
+
"eslint": "^9.10.0",
|
|
23
|
+
"globals": "^15.9.0",
|
|
24
|
+
"nodemon": "^3.1.2",
|
|
25
|
+
"ts-node": "^10.9.2",
|
|
26
|
+
"typescript": "^5.4.5",
|
|
27
|
+
"typescript-eslint": "^8.5.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"dotenv": "^16.4.5"
|
|
31
|
+
}
|
|
32
|
+
}
|