gamerbot-module 1.1.1 → 1.2.0
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/package.json +1 -1
- package/dist/classes/ConfigData.d.ts +0 -17
- package/dist/classes/ConfigData.js +0 -52
- package/dist/classes/GuildData.d.ts +0 -26
- package/dist/classes/GuildData.js +0 -61
- package/dist/classes/ProfileData.d.ts +0 -28
- package/dist/classes/ProfileData.js +0 -63
- package/dist/classes/config_data.d.ts +0 -17
- package/dist/classes/config_data.js +0 -41
- package/dist/classes/gamerbot.d.ts +0 -13
- package/dist/classes/gamerbot.js +0 -54
- package/dist/classes/guild_data.d.ts +0 -24
- package/dist/classes/guild_data.js +0 -48
- package/dist/classes/models.d.ts +0 -47
- package/dist/classes/models.js +0 -130
- package/dist/classes/profile_data.d.ts +0 -21
- package/dist/classes/profile_data.js +0 -22
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -5
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { GamerBotAPI } from "./gamerbot.js";
|
|
2
|
-
export class ConfigData {
|
|
3
|
-
// eslint-disable-next-line
|
|
4
|
-
constructor(json_data) {
|
|
5
|
-
this.json_data = JSON.parse(JSON.stringify(json_data));
|
|
6
|
-
this.id = json_data.id;
|
|
7
|
-
this.debug = json_data.debug;
|
|
8
|
-
this.username = json_data.username;
|
|
9
|
-
this.activity = json_data.activity;
|
|
10
|
-
this.activityType = json_data.activityType;
|
|
11
|
-
this.removeLinks = json_data.removeLinks;
|
|
12
|
-
this.xp = json_data.xp;
|
|
13
|
-
this.importantUpdatesChannelId = json_data.importantUpdatesChannelId;
|
|
14
|
-
this.debugGuildID = json_data.debugGuildID;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Saves config data to database
|
|
18
|
-
*/
|
|
19
|
-
async save() {
|
|
20
|
-
return new Promise((resolve) => {
|
|
21
|
-
// eslint-disable-next-line
|
|
22
|
-
const changed_data = {};
|
|
23
|
-
Object.keys(this).forEach((key) => {
|
|
24
|
-
if (key == "json_data")
|
|
25
|
-
return;
|
|
26
|
-
const value = Object.entries(this).find(([k, v]) => {
|
|
27
|
-
if (k != key)
|
|
28
|
-
return false;
|
|
29
|
-
return JSON.stringify(v) != JSON.stringify(this.json_data[key]);
|
|
30
|
-
});
|
|
31
|
-
if (value)
|
|
32
|
-
changed_data[key] = value[1];
|
|
33
|
-
});
|
|
34
|
-
if (Object.keys(changed_data).length == 0)
|
|
35
|
-
return resolve(changed_data);
|
|
36
|
-
fetch(GamerBotAPI.API_URL + "/api/config/" + this.id, {
|
|
37
|
-
method: "POST",
|
|
38
|
-
body: JSON.stringify(changed_data),
|
|
39
|
-
headers: {
|
|
40
|
-
"Content-Type": "application/json",
|
|
41
|
-
authorization: "Bearer " + GamerBotAPI.TOKEN,
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
.then((response) => {
|
|
45
|
-
resolve(response);
|
|
46
|
-
})
|
|
47
|
-
.catch((err) => {
|
|
48
|
-
console.error(err);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
frameConfig: Array<object>;
|
|
19
|
-
json_data: any;
|
|
20
|
-
extraObjects: Map<string, any>;
|
|
21
|
-
constructor(json_data: any);
|
|
22
|
-
/**
|
|
23
|
-
* Saves guild data to database
|
|
24
|
-
*/
|
|
25
|
-
save(): Promise<unknown>;
|
|
26
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { GamerBotAPI } from "./gamerbot.js";
|
|
2
|
-
export class GuildData {
|
|
3
|
-
//eslint-disable-next-line
|
|
4
|
-
constructor(json_data) {
|
|
5
|
-
this.json_data = JSON.parse(JSON.stringify(json_data));
|
|
6
|
-
this.guildID = json_data.guildID;
|
|
7
|
-
this.privateVoiceChannel = json_data.privateVoiceChannel;
|
|
8
|
-
this.publicVoiceChannel = json_data.publicVoiceChannel;
|
|
9
|
-
this.infoVoiceChannel = json_data.infoVoiceChannel;
|
|
10
|
-
this.notificationChannel = json_data.notificationChannel;
|
|
11
|
-
this.ticketParent = json_data.ticketParent;
|
|
12
|
-
this.archivedTicketParent = json_data.archivedTicketParent;
|
|
13
|
-
this.allowedLinksChannels = json_data.allowedLinksChannels;
|
|
14
|
-
this.trustedLinkRoles = json_data.trustedLinkRoles;
|
|
15
|
-
this.noXpChannels = json_data.noXpChannels;
|
|
16
|
-
this.whitelistedLinks = json_data.whitelistedLinks;
|
|
17
|
-
this.threedChannels = json_data.threedChannels;
|
|
18
|
-
this.bansTimes = json_data.bansTimes;
|
|
19
|
-
this.topicList = json_data.topicList;
|
|
20
|
-
this.staffModlogs = json_data.staffModlogs;
|
|
21
|
-
this.sverokMails = json_data.sverokMails;
|
|
22
|
-
this.frameConfig = json_data.frameConfig;
|
|
23
|
-
this.extraObjects = json_data.extraObjects;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Saves guild data to database
|
|
27
|
-
*/
|
|
28
|
-
async save() {
|
|
29
|
-
return new Promise((resolve) => {
|
|
30
|
-
//eslint-disable-next-line
|
|
31
|
-
const changed_data = {};
|
|
32
|
-
Object.keys(this).forEach((key) => {
|
|
33
|
-
if (key == "json_data")
|
|
34
|
-
return;
|
|
35
|
-
const value = Object.entries(this).find(([k, v]) => {
|
|
36
|
-
if (k != key)
|
|
37
|
-
return false;
|
|
38
|
-
return JSON.stringify(v) != JSON.stringify(this.json_data[key]);
|
|
39
|
-
});
|
|
40
|
-
if (value)
|
|
41
|
-
changed_data[key] = value[1];
|
|
42
|
-
});
|
|
43
|
-
if (Object.keys(changed_data).length == 0)
|
|
44
|
-
return resolve(changed_data);
|
|
45
|
-
fetch(GamerBotAPI.API_URL + "/api/guild/" + this.guildID, {
|
|
46
|
-
method: "POST",
|
|
47
|
-
body: JSON.stringify(changed_data),
|
|
48
|
-
headers: {
|
|
49
|
-
"Content-Type": "application/json",
|
|
50
|
-
authorization: "Bearer " + GamerBotAPI.TOKEN,
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
.then((response) => {
|
|
54
|
-
resolve(response);
|
|
55
|
-
})
|
|
56
|
-
.catch((err) => {
|
|
57
|
-
console.error(err);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare class PorfileData {
|
|
2
|
-
userID: string;
|
|
3
|
-
serverID: string;
|
|
4
|
-
xp: number;
|
|
5
|
-
lastMessageTimestamp: number;
|
|
6
|
-
xpTimeoutUntil: number;
|
|
7
|
-
level: number;
|
|
8
|
-
reminders: Array<object>;
|
|
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
|
-
old_messages: Array<string>;
|
|
21
|
-
hashed_email: string;
|
|
22
|
-
json_data: any;
|
|
23
|
-
constructor(json_data: any);
|
|
24
|
-
/**
|
|
25
|
-
* Saves user data to database
|
|
26
|
-
*/
|
|
27
|
-
save(): Promise<unknown>;
|
|
28
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { GamerBotAPI } from "./gamerbot.js";
|
|
2
|
-
export class PorfileData {
|
|
3
|
-
// eslint-disable-next-line
|
|
4
|
-
constructor(json_data) {
|
|
5
|
-
this.json_data = JSON.parse(JSON.stringify(json_data));
|
|
6
|
-
this.userID = json_data.userID;
|
|
7
|
-
this.serverID = json_data.serverID;
|
|
8
|
-
this.xp = json_data.xp;
|
|
9
|
-
this.lastMessageTimestamp = json_data.lastMessageTimestamp;
|
|
10
|
-
this.xpTimeoutUntil = json_data.xpTimeoutUntil;
|
|
11
|
-
this.level = json_data.level;
|
|
12
|
-
this.reminders = json_data.reminders;
|
|
13
|
-
this.colorHexCode = json_data.colorHexCode;
|
|
14
|
-
this.privateVoiceID = json_data.privateVoiceID;
|
|
15
|
-
this.privateVoiceThreadID = json_data.privateVoiceThreadID;
|
|
16
|
-
this.profileFrame = json_data.profileFrame;
|
|
17
|
-
this.hasLeftTicket = json_data.hasLeftTicket;
|
|
18
|
-
this.xpboost = json_data.xpboost;
|
|
19
|
-
this.exclusiveFrames = json_data.exclusiveFrames;
|
|
20
|
-
this.modLogs = json_data.modLogs;
|
|
21
|
-
this.minecraftWhiteList = json_data.minecraftWhiteList;
|
|
22
|
-
this.minecraftUsername = json_data.minecraftUsername;
|
|
23
|
-
this.minecraftUuid = json_data.minecraftUuid;
|
|
24
|
-
this.old_messages = json_data.old_messages;
|
|
25
|
-
this.hashed_email = json_data.hashed_email;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Saves user data to database
|
|
29
|
-
*/
|
|
30
|
-
async save() {
|
|
31
|
-
return new Promise((resolve) => {
|
|
32
|
-
// eslint-disable-next-line
|
|
33
|
-
const changed_data = {};
|
|
34
|
-
Object.keys(this).forEach((key) => {
|
|
35
|
-
if (key == "json_data")
|
|
36
|
-
return;
|
|
37
|
-
const value = Object.entries(this).find(([k, v]) => {
|
|
38
|
-
if (k != key)
|
|
39
|
-
return false;
|
|
40
|
-
return JSON.stringify(v) != JSON.stringify(this.json_data[key]);
|
|
41
|
-
});
|
|
42
|
-
if (value)
|
|
43
|
-
changed_data[key] = value[1];
|
|
44
|
-
});
|
|
45
|
-
if (Object.keys(changed_data).length == 0)
|
|
46
|
-
return resolve(changed_data);
|
|
47
|
-
fetch(GamerBotAPI.API_URL + "/api/user/" + this.userID, {
|
|
48
|
-
method: "POST",
|
|
49
|
-
body: JSON.stringify(changed_data),
|
|
50
|
-
headers: {
|
|
51
|
-
"Content-Type": "application/json",
|
|
52
|
-
authorization: "Bearer " + GamerBotAPI.TOKEN,
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
.then((response) => {
|
|
56
|
-
resolve(response);
|
|
57
|
-
})
|
|
58
|
-
.catch((err) => {
|
|
59
|
-
console.error(err);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Models } from "./models.js";
|
|
2
|
-
/**
|
|
3
|
-
* GamerBotAPI class, connect to the gamerbot API
|
|
4
|
-
*/
|
|
5
|
-
export declare class GamerBotAPI {
|
|
6
|
-
static TOKEN: string;
|
|
7
|
-
static API_URL: string;
|
|
8
|
-
apiStatus: boolean;
|
|
9
|
-
models: Models;
|
|
10
|
-
constructor(TOKEN: string, dev?: boolean);
|
|
11
|
-
getAPIStatus(): Promise<void>;
|
|
12
|
-
static arraysEqual<T>(a: Array<T>, b: Array<T>): boolean;
|
|
13
|
-
}
|
package/dist/classes/gamerbot.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Models } from "./models.js";
|
|
2
|
-
/**
|
|
3
|
-
* GamerBotAPI class, connect to the gamerbot API
|
|
4
|
-
*/
|
|
5
|
-
export class GamerBotAPI {
|
|
6
|
-
constructor(TOKEN, dev = false) {
|
|
7
|
-
this.apiStatus = false;
|
|
8
|
-
GamerBotAPI.TOKEN = TOKEN;
|
|
9
|
-
this.models = new Models();
|
|
10
|
-
// If dev is true, we will use the local API
|
|
11
|
-
if (dev) {
|
|
12
|
-
GamerBotAPI.API_URL = "http://localhost:3000";
|
|
13
|
-
}
|
|
14
|
-
this.getAPIStatus().then(() => {
|
|
15
|
-
console.log("API is available");
|
|
16
|
-
this.apiStatus = true;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async getAPIStatus() {
|
|
20
|
-
const response = await fetch(GamerBotAPI.API_URL);
|
|
21
|
-
const data = await response.json().catch(() => {
|
|
22
|
-
console.error("API is not available, trying to connect to the API again in 5 seconds");
|
|
23
|
-
setTimeout(() => {
|
|
24
|
-
this.getAPIStatus();
|
|
25
|
-
}, 5000);
|
|
26
|
-
});
|
|
27
|
-
if (data.service == "OK")
|
|
28
|
-
return;
|
|
29
|
-
else {
|
|
30
|
-
console.error("API is not available, trying to connect to the API again in 5 seconds");
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
this.getAPIStatus();
|
|
33
|
-
}, 5000);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
static arraysEqual(a, b) {
|
|
37
|
-
if (a === b)
|
|
38
|
-
return true;
|
|
39
|
-
if (a == null || b == null)
|
|
40
|
-
return false;
|
|
41
|
-
if (a.length !== b.length)
|
|
42
|
-
return false;
|
|
43
|
-
for (let i = 0; i < a.length; ++i) {
|
|
44
|
-
if (typeof a[i] === 'object' && typeof b[i] === 'object') {
|
|
45
|
-
if (!this.arraysEqual(Object.entries(a[i]), Object.entries(b[i])))
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
else if (a[i] !== b[i])
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
GamerBotAPI.API_URL = "https://api.sgc.se";
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/classes/models.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ConfigData } from "./ConfigData.js";
|
|
2
|
-
import { GuildData } from "./GuildData.js";
|
|
3
|
-
import { PorfileData } from "./ProfileData.js";
|
|
4
|
-
export declare class Models {
|
|
5
|
-
constructor();
|
|
6
|
-
/**
|
|
7
|
-
* get profile data
|
|
8
|
-
* @param user_id discord user id
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
get_profile_data(user_id: string): Promise<PorfileData>;
|
|
12
|
-
/**
|
|
13
|
-
* get all profile data
|
|
14
|
-
* @param max_users amount of users to fetch
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
get_all_profile_data(max_users: number, filter?: object): Promise<PorfileData[]>;
|
|
18
|
-
/**
|
|
19
|
-
* get config data
|
|
20
|
-
* @param id config id
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
get_config_data(id: number): Promise<ConfigData>;
|
|
24
|
-
/**
|
|
25
|
-
* get guild data
|
|
26
|
-
* @param guild_id discord guild id
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
get_guild_data(guild_id: string): Promise<GuildData>;
|
|
30
|
-
/**
|
|
31
|
-
* Get users frame
|
|
32
|
-
* @param user_id
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
get_user_frame(user_id: string, username: string, avatar_url: string, force?: boolean): Promise<Buffer>;
|
|
36
|
-
get_frame_config(guild_id: string): Promise<any>;
|
|
37
|
-
/**
|
|
38
|
-
* Gets frame image
|
|
39
|
-
*/
|
|
40
|
-
get_frame(guild_id: string, frame_id: string): Promise<Buffer>;
|
|
41
|
-
/**
|
|
42
|
-
* Get users frame
|
|
43
|
-
* @param user_id
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
private fetch_data;
|
|
47
|
-
}
|
package/dist/classes/models.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { ConfigData } from "./ConfigData.js";
|
|
2
|
-
import { GamerBotAPI } from "./gamerbot.js";
|
|
3
|
-
import { GuildData } from "./GuildData.js";
|
|
4
|
-
import { PorfileData } from "./ProfileData.js";
|
|
5
|
-
export class Models {
|
|
6
|
-
constructor() { }
|
|
7
|
-
/**
|
|
8
|
-
* get profile data
|
|
9
|
-
* @param user_id discord user id
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
async get_profile_data(user_id) {
|
|
13
|
-
const data = await this.fetch_data(GamerBotAPI.API_URL + "/api/user/" + user_id);
|
|
14
|
-
const profile_data = new PorfileData(data);
|
|
15
|
-
return profile_data;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* get all profile data
|
|
19
|
-
* @param max_users amount of users to fetch
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
async get_all_profile_data(max_users, filter = {}) {
|
|
23
|
-
const data = (await this.fetch_data(GamerBotAPI.API_URL + "/api/user/fetch_many", "POST", { maxUsers: max_users, filter: filter }));
|
|
24
|
-
const profile_data = [];
|
|
25
|
-
// eslint-disable-next-line
|
|
26
|
-
data.forEach((element) => {
|
|
27
|
-
profile_data.push(new PorfileData(element));
|
|
28
|
-
});
|
|
29
|
-
return profile_data;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* get config data
|
|
33
|
-
* @param id config id
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
async get_config_data(id) {
|
|
37
|
-
const data = await this.fetch_data(GamerBotAPI.API_URL + "/api/config/" + id);
|
|
38
|
-
const config_data = new ConfigData(data);
|
|
39
|
-
return config_data;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* get guild data
|
|
43
|
-
* @param guild_id discord guild id
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
async get_guild_data(guild_id) {
|
|
47
|
-
const data = await this.fetch_data(GamerBotAPI.API_URL + "/api/guild/" + guild_id);
|
|
48
|
-
return new GuildData(data);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Get users frame
|
|
52
|
-
* @param user_id
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
async get_user_frame(user_id, username, avatar_url, force = false) {
|
|
56
|
-
const profile_data = await this.get_profile_data(user_id);
|
|
57
|
-
let xpPercentage = Math.round((profile_data.xp / profile_data.level ** 2) * 100);
|
|
58
|
-
// Progressbar is constant after lvl 31
|
|
59
|
-
if (profile_data.level > 31) {
|
|
60
|
-
xpPercentage = Math.round((profile_data.xp / 961) * 100);
|
|
61
|
-
}
|
|
62
|
-
if (!profile_data.colorHexCode)
|
|
63
|
-
profile_data.colorHexCode = "#000000";
|
|
64
|
-
const data = (await this.fetch_data(GamerBotAPI.API_URL + "/public_api/frame/generate", "POST", {
|
|
65
|
-
userid: user_id,
|
|
66
|
-
frame_id: profile_data.profileFrame,
|
|
67
|
-
hex_color: profile_data.colorHexCode,
|
|
68
|
-
username: username,
|
|
69
|
-
level: profile_data.level - 1,
|
|
70
|
-
xp_percentage: xpPercentage,
|
|
71
|
-
avatar_url: avatar_url,
|
|
72
|
-
force: force,
|
|
73
|
-
}, false));
|
|
74
|
-
return Buffer.from(await data.arrayBuffer());
|
|
75
|
-
}
|
|
76
|
-
async get_frame_config(guild_id) {
|
|
77
|
-
const data = await this.fetch_data(GamerBotAPI.API_URL + "/public_api/frame/get/config", "POST", { guildId: guild_id });
|
|
78
|
-
return data;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Gets frame image
|
|
82
|
-
*/
|
|
83
|
-
async get_frame(guild_id, frame_id) {
|
|
84
|
-
const data = (await this.fetch_data(GamerBotAPI.API_URL +
|
|
85
|
-
"/public_api/frame/get/" +
|
|
86
|
-
guild_id +
|
|
87
|
-
"/" +
|
|
88
|
-
frame_id, "GET", null, false));
|
|
89
|
-
return Buffer.from(await data.arrayBuffer());
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Get users frame
|
|
93
|
-
* @param user_id
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
fetch_data(url, method = "GET",
|
|
97
|
-
// eslint-disable-next-line
|
|
98
|
-
json_data = null, convert_to_json = true) {
|
|
99
|
-
json_data = json_data ? JSON.stringify(json_data) : null;
|
|
100
|
-
return new Promise((resolve, reject) => {
|
|
101
|
-
fetch(url, {
|
|
102
|
-
method: method,
|
|
103
|
-
body: json_data,
|
|
104
|
-
headers: {
|
|
105
|
-
"Content-Type": "application/json",
|
|
106
|
-
authorization: "Bearer " + GamerBotAPI.TOKEN,
|
|
107
|
-
},
|
|
108
|
-
})
|
|
109
|
-
.then(async (response) => {
|
|
110
|
-
if (!response.ok) {
|
|
111
|
-
const error = await response.json();
|
|
112
|
-
console.error("Error fetching data: ", error);
|
|
113
|
-
reject(error);
|
|
114
|
-
}
|
|
115
|
-
if (!convert_to_json)
|
|
116
|
-
return response;
|
|
117
|
-
else
|
|
118
|
-
return response.json();
|
|
119
|
-
})
|
|
120
|
-
.then((data) => {
|
|
121
|
-
resolve(data);
|
|
122
|
-
})
|
|
123
|
-
.catch((error) => {
|
|
124
|
-
console.error("Error fetching data: ", error);
|
|
125
|
-
reject(error);
|
|
126
|
-
});
|
|
127
|
-
// eslint-disable-next-line
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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/dist/index.d.ts
DELETED
package/dist/index.js
DELETED