gamerbot-module 1.2.3 → 2.1.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/dist/classes/ConfigData.d.ts +16 -10
- package/dist/classes/ConfigData.js +45 -37
- package/dist/classes/GuildData.d.ts +33 -20
- package/dist/classes/GuildData.js +49 -47
- package/dist/classes/MinecraftData.d.ts +6 -0
- package/dist/classes/MinecraftData.js +8 -0
- package/dist/classes/UserData.d.ts +52 -0
- package/dist/classes/UserData.js +64 -0
- package/dist/classes/gamerbot.d.ts +0 -1
- package/dist/classes/gamerbot.js +0 -17
- package/dist/classes/models.d.ts +36 -20
- package/dist/classes/models.js +85 -61
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/package.json +31 -12
- 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/guild_data.d.ts +0 -24
- package/dist/classes/guild_data.js +0 -48
- package/dist/classes/profile_data.d.ts +0 -21
- package/dist/classes/profile_data.js +0 -22
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
export declare class ConfigData {
|
|
2
2
|
id: number;
|
|
3
3
|
debug: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
importantUpdatesChannelId: object;
|
|
10
|
-
debugGuildID: string;
|
|
11
|
-
json_data: any;
|
|
12
|
-
constructor(json_data: any);
|
|
4
|
+
levelSystem: LevelSystem;
|
|
5
|
+
debugGuildId: string;
|
|
6
|
+
extraObjects: Map<string, object>;
|
|
7
|
+
jsonData: any;
|
|
8
|
+
constructor(jsonData: any);
|
|
13
9
|
/**
|
|
14
10
|
* Saves config data to database
|
|
15
11
|
*/
|
|
16
|
-
save(): Promise<
|
|
12
|
+
save(): Promise<any>;
|
|
17
13
|
}
|
|
14
|
+
interface LevelSystem {
|
|
15
|
+
levelExponent: number;
|
|
16
|
+
levels: Array<Level>;
|
|
17
|
+
}
|
|
18
|
+
export interface Level {
|
|
19
|
+
ids: Array<string>;
|
|
20
|
+
level: number;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -1,52 +1,60 @@
|
|
|
1
1
|
import { GamerBotAPI } from "./gamerbot.js";
|
|
2
2
|
export class ConfigData {
|
|
3
3
|
// eslint-disable-next-line
|
|
4
|
-
constructor(
|
|
5
|
-
this.
|
|
6
|
-
this.id =
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.removeLinks = json_data.removeLinks;
|
|
12
|
-
this.xp = json_data.xp;
|
|
13
|
-
this.importantUpdatesChannelId = json_data.importantUpdatesChannelId;
|
|
14
|
-
this.debugGuildID = json_data.debugGuildID;
|
|
4
|
+
constructor(jsonData) {
|
|
5
|
+
this.jsonData = JSON.parse(JSON.stringify(jsonData));
|
|
6
|
+
this.id = jsonData.id;
|
|
7
|
+
this.debugGuildId = jsonData.debugGuildId;
|
|
8
|
+
this.debug = jsonData.debug;
|
|
9
|
+
this.levelSystem = jsonData.levelSystem;
|
|
10
|
+
this.extraObjects = new Map(Object.entries(jsonData.extraObjects));
|
|
15
11
|
}
|
|
16
12
|
/**
|
|
17
13
|
* Saves config data to database
|
|
18
14
|
*/
|
|
19
15
|
async save() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
16
|
+
// eslint-disable-next-line
|
|
17
|
+
const changedData = {};
|
|
18
|
+
for (const key of Object.keys(this)) {
|
|
19
|
+
if (key == "jsonData")
|
|
20
|
+
continue;
|
|
21
|
+
const currentValue = this[key];
|
|
22
|
+
const jsonValue = this.jsonData[key];
|
|
23
|
+
if (key === "extraObjects" && currentValue instanceof Map) {
|
|
24
|
+
const mapAsObject = Object.fromEntries(currentValue);
|
|
25
|
+
if (JSON.stringify(mapAsObject) !== JSON.stringify(jsonValue)) {
|
|
26
|
+
changedData[key] = mapAsObject;
|
|
27
|
+
}
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (typeof currentValue === "object" && currentValue !== null) {
|
|
31
|
+
if (JSON.stringify(currentValue) !== JSON.stringify(jsonValue)) {
|
|
32
|
+
changedData[key] = currentValue;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (currentValue !== jsonValue) {
|
|
36
|
+
changedData[key] = currentValue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (Object.keys(changedData).length > 0) {
|
|
40
|
+
const jsonData = await fetch(GamerBotAPI.API_URL + "/api/config/" + this.id, {
|
|
37
41
|
method: "POST",
|
|
38
|
-
body: JSON.stringify(
|
|
42
|
+
body: JSON.stringify(changedData),
|
|
39
43
|
headers: {
|
|
40
44
|
"Content-Type": "application/json",
|
|
41
45
|
authorization: "Bearer " + GamerBotAPI.TOKEN,
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
.then((response) => {
|
|
45
|
-
resolve(response);
|
|
46
|
-
})
|
|
47
|
-
.catch((err) => {
|
|
48
|
-
console.error(err);
|
|
46
|
+
}
|
|
49
47
|
});
|
|
50
|
-
|
|
48
|
+
if (!jsonData.ok) {
|
|
49
|
+
console.error("Failed to save config data:", await jsonData.text());
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.jsonData = {
|
|
53
|
+
...this.jsonData,
|
|
54
|
+
...changedData,
|
|
55
|
+
};
|
|
56
|
+
const data = await jsonData.json();
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
51
59
|
}
|
|
52
60
|
}
|
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
export declare class GuildData {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ticketParent: string;
|
|
8
|
-
archivedTicketParent: string;
|
|
9
|
-
allowedLinksChannels: Array<string>;
|
|
10
|
-
trustedLinkRoles: Array<string>;
|
|
2
|
+
guildId: string;
|
|
3
|
+
voiceChannelData: voiceChannelData;
|
|
4
|
+
ticketData: ticketData;
|
|
5
|
+
autoModeration: autoModeration;
|
|
6
|
+
topics: Array<string>;
|
|
11
7
|
noXpChannels: Array<string>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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);
|
|
8
|
+
frames: Array<frameData>;
|
|
9
|
+
extraObjects: Map<string, object>;
|
|
10
|
+
jsonData: any;
|
|
11
|
+
constructor(jsonData: any);
|
|
22
12
|
/**
|
|
23
13
|
* Saves guild data to database
|
|
24
14
|
*/
|
|
25
|
-
save(): Promise<
|
|
15
|
+
save(): Promise<any>;
|
|
16
|
+
}
|
|
17
|
+
interface voiceChannelData {
|
|
18
|
+
voiceChannelId: string;
|
|
19
|
+
infoChatId: string;
|
|
20
|
+
}
|
|
21
|
+
interface ticketData {
|
|
22
|
+
ticketCategoryId: string;
|
|
23
|
+
archivedTicketCategoryId: string;
|
|
24
|
+
}
|
|
25
|
+
interface autoModeration {
|
|
26
|
+
linkFilter: boolean;
|
|
27
|
+
trustedLinkRoles: Array<string>;
|
|
28
|
+
linkChannels: Array<string>;
|
|
29
|
+
whitelistedLinks: Array<string>;
|
|
30
|
+
bannedUsers: Array<object>;
|
|
31
|
+
modLogChannelId: string;
|
|
32
|
+
}
|
|
33
|
+
interface frameData {
|
|
34
|
+
name: string;
|
|
35
|
+
path: string;
|
|
36
|
+
id: string;
|
|
37
|
+
foregroundPath: string;
|
|
26
38
|
}
|
|
39
|
+
export {};
|
|
@@ -1,61 +1,63 @@
|
|
|
1
1
|
import { GamerBotAPI } from "./gamerbot.js";
|
|
2
2
|
export class GuildData {
|
|
3
|
-
//eslint-disable-next-line
|
|
4
|
-
constructor(
|
|
5
|
-
this.
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
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 = new Map(Object.entries(json_data.extraObjects));
|
|
3
|
+
// eslint-disable-next-line
|
|
4
|
+
constructor(jsonData) {
|
|
5
|
+
this.jsonData = JSON.parse(JSON.stringify(jsonData));
|
|
6
|
+
this.guildId = jsonData.guildId;
|
|
7
|
+
this.voiceChannelData = jsonData.voiceChannelData;
|
|
8
|
+
this.ticketData = jsonData.ticketData;
|
|
9
|
+
this.autoModeration = jsonData.autoModeration;
|
|
10
|
+
this.topics = jsonData.topics;
|
|
11
|
+
this.noXpChannels = jsonData.noXpChannels;
|
|
12
|
+
this.frames = jsonData.frames;
|
|
13
|
+
this.extraObjects = new Map(Object.entries(jsonData.extraObjects));
|
|
24
14
|
}
|
|
25
15
|
/**
|
|
26
16
|
* Saves guild data to database
|
|
27
17
|
*/
|
|
28
18
|
async save() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
19
|
+
// eslint-disable-next-line
|
|
20
|
+
const changedData = {};
|
|
21
|
+
for (const key of Object.keys(this)) {
|
|
22
|
+
if (key == "jsonData")
|
|
23
|
+
continue;
|
|
24
|
+
const currentValue = this[key];
|
|
25
|
+
const jsonValue = this.jsonData[key];
|
|
26
|
+
if (key === "extraObjects" && currentValue instanceof Map) {
|
|
27
|
+
const mapAsObject = Object.fromEntries(currentValue);
|
|
28
|
+
if (JSON.stringify(mapAsObject) !== JSON.stringify(jsonValue)) {
|
|
29
|
+
changedData[key] = mapAsObject;
|
|
30
|
+
}
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (typeof currentValue === "object" && currentValue !== null) {
|
|
34
|
+
if (JSON.stringify(currentValue) !== JSON.stringify(jsonValue)) {
|
|
35
|
+
changedData[key] = currentValue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (currentValue !== jsonValue) {
|
|
39
|
+
changedData[key] = currentValue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (Object.keys(changedData).length > 0) {
|
|
43
|
+
const jsonData = await fetch(GamerBotAPI.API_URL + "/api/guild/" + this.guildId, {
|
|
46
44
|
method: "POST",
|
|
47
|
-
body: JSON.stringify(
|
|
45
|
+
body: JSON.stringify(changedData),
|
|
48
46
|
headers: {
|
|
49
47
|
"Content-Type": "application/json",
|
|
50
48
|
authorization: "Bearer " + GamerBotAPI.TOKEN,
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
.then((response) => {
|
|
54
|
-
resolve(response);
|
|
55
|
-
})
|
|
56
|
-
.catch((err) => {
|
|
57
|
-
console.error(err);
|
|
49
|
+
}
|
|
58
50
|
});
|
|
59
|
-
|
|
51
|
+
if (!jsonData.ok) {
|
|
52
|
+
console.error("Failed to save config data:", await jsonData.text());
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.jsonData = {
|
|
56
|
+
...this.jsonData,
|
|
57
|
+
...changedData,
|
|
58
|
+
};
|
|
59
|
+
const data = await jsonData.json();
|
|
60
|
+
return data;
|
|
61
|
+
}
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare class UserData {
|
|
2
|
+
userId: string;
|
|
3
|
+
levelSystem: LevelSystem;
|
|
4
|
+
frameData: FrameData;
|
|
5
|
+
voiceData: VoiceData;
|
|
6
|
+
modLogs: Array<ModLog>;
|
|
7
|
+
minecraftData: MinecraftData;
|
|
8
|
+
hashedEmail: string;
|
|
9
|
+
reminders: Array<Reminder>;
|
|
10
|
+
extraObjects: Map<string, object>;
|
|
11
|
+
jsonData: any;
|
|
12
|
+
constructor(jsonData: any);
|
|
13
|
+
/**
|
|
14
|
+
* Saves user data to database
|
|
15
|
+
*/
|
|
16
|
+
save(): Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
interface LevelSystem {
|
|
19
|
+
level: number;
|
|
20
|
+
xp: number;
|
|
21
|
+
xpTimeoutUntil: number;
|
|
22
|
+
lastMessageTimestamp: number;
|
|
23
|
+
oldMessages: Array<string>;
|
|
24
|
+
}
|
|
25
|
+
interface FrameData {
|
|
26
|
+
frameColorHexCode: string;
|
|
27
|
+
selectedFrame: number;
|
|
28
|
+
frames: Array<string>;
|
|
29
|
+
}
|
|
30
|
+
interface VoiceData {
|
|
31
|
+
voiceChannelId: string;
|
|
32
|
+
voiceChannelThreadId: string;
|
|
33
|
+
}
|
|
34
|
+
interface MinecraftData {
|
|
35
|
+
uuid: string;
|
|
36
|
+
username: string;
|
|
37
|
+
}
|
|
38
|
+
interface ModLog {
|
|
39
|
+
type: string;
|
|
40
|
+
userId: string;
|
|
41
|
+
username: string;
|
|
42
|
+
reason: string;
|
|
43
|
+
timestamp: number;
|
|
44
|
+
length: string | null;
|
|
45
|
+
authorId: string;
|
|
46
|
+
}
|
|
47
|
+
export interface Reminder {
|
|
48
|
+
message: string;
|
|
49
|
+
userId: string;
|
|
50
|
+
timestamp: number;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { GamerBotAPI } from "./gamerbot.js";
|
|
2
|
+
export class UserData {
|
|
3
|
+
// eslint-disable-next-line
|
|
4
|
+
constructor(jsonData) {
|
|
5
|
+
this.jsonData = JSON.parse(JSON.stringify(jsonData));
|
|
6
|
+
this.userId = jsonData.userId;
|
|
7
|
+
this.levelSystem = jsonData.levelSystem;
|
|
8
|
+
this.frameData = jsonData.frameData;
|
|
9
|
+
this.voiceData = jsonData.voiceData;
|
|
10
|
+
this.modLogs = jsonData.modLogs;
|
|
11
|
+
this.minecraftData = jsonData.minecraftData;
|
|
12
|
+
this.hashedEmail = jsonData.hashedEmail;
|
|
13
|
+
this.reminders = jsonData.reminders;
|
|
14
|
+
this.extraObjects = new Map(Object.entries(jsonData.extraObjects));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Saves user data to database
|
|
18
|
+
*/
|
|
19
|
+
async save() {
|
|
20
|
+
// eslint-disable-next-line
|
|
21
|
+
const changedData = {};
|
|
22
|
+
for (const key of Object.keys(this)) {
|
|
23
|
+
if (key == "jsonData")
|
|
24
|
+
continue;
|
|
25
|
+
const currentValue = this[key];
|
|
26
|
+
const jsonValue = this.jsonData[key];
|
|
27
|
+
if (key === "extraObjects" && currentValue instanceof Map) {
|
|
28
|
+
const mapAsObject = Object.fromEntries(currentValue);
|
|
29
|
+
if (JSON.stringify(mapAsObject) !== JSON.stringify(jsonValue)) {
|
|
30
|
+
changedData[key] = mapAsObject;
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (typeof currentValue === "object" && currentValue !== null) {
|
|
35
|
+
if (JSON.stringify(currentValue) !== JSON.stringify(jsonValue)) {
|
|
36
|
+
changedData[key] = currentValue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (currentValue !== jsonValue) {
|
|
40
|
+
changedData[key] = currentValue;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (Object.keys(changedData).length > 0) {
|
|
44
|
+
const jsonData = await fetch(GamerBotAPI.API_URL + "/api/user/" + this.userId, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
body: JSON.stringify(changedData),
|
|
47
|
+
headers: {
|
|
48
|
+
"Content-Type": "application/json",
|
|
49
|
+
authorization: "Bearer " + GamerBotAPI.TOKEN,
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (!jsonData.ok) {
|
|
53
|
+
console.error("Failed to save config data:", await jsonData.text());
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.jsonData = {
|
|
57
|
+
...this.jsonData,
|
|
58
|
+
...changedData,
|
|
59
|
+
};
|
|
60
|
+
const data = await jsonData.json();
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
package/dist/classes/gamerbot.js
CHANGED
|
@@ -46,22 +46,5 @@ export class GamerBotAPI {
|
|
|
46
46
|
}
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
|
-
static arraysEqual(a, b) {
|
|
50
|
-
if (a === b)
|
|
51
|
-
return true;
|
|
52
|
-
if (a == null || b == null)
|
|
53
|
-
return false;
|
|
54
|
-
if (a.length !== b.length)
|
|
55
|
-
return false;
|
|
56
|
-
for (let i = 0; i < a.length; ++i) {
|
|
57
|
-
if (typeof a[i] === 'object' && typeof b[i] === 'object') {
|
|
58
|
-
if (!this.arraysEqual(Object.entries(a[i]), Object.entries(b[i])))
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
else if (a[i] !== b[i])
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
49
|
}
|
|
67
50
|
GamerBotAPI.API_URL = "https://api.sgc.se";
|
package/dist/classes/models.d.ts
CHANGED
|
@@ -1,47 +1,63 @@
|
|
|
1
1
|
import { ConfigData } from "./ConfigData.js";
|
|
2
2
|
import { GuildData } from "./GuildData.js";
|
|
3
|
-
import {
|
|
3
|
+
import { MinecraftData } from "./MinecraftData.js";
|
|
4
|
+
import { UserData } from "./UserData.js";
|
|
4
5
|
export declare class Models {
|
|
6
|
+
cachedUsersFrames: Map<string, UserFrameData>;
|
|
5
7
|
constructor();
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param
|
|
9
|
+
* Get user data
|
|
10
|
+
* @param userId discord user id
|
|
9
11
|
* @returns
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
getUserData(userId: string): Promise<UserData>;
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
15
|
+
* Get multiple users data
|
|
16
|
+
* @param maxUsers amount of users to fetch
|
|
15
17
|
* @returns
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
getAllUserData(maxUsers: number, filter?: object): Promise<UserData[]>;
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
21
|
+
* Get config data
|
|
20
22
|
* @param id config id
|
|
21
23
|
* @returns
|
|
22
24
|
*/
|
|
23
|
-
|
|
25
|
+
getConfigData(id: number): Promise<ConfigData>;
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param
|
|
27
|
+
* Get guild data
|
|
28
|
+
* @param guildId discord guild id
|
|
27
29
|
* @returns
|
|
28
30
|
*/
|
|
29
|
-
|
|
31
|
+
getGuildData(guildId: string): Promise<GuildData>;
|
|
30
32
|
/**
|
|
31
33
|
* Get users frame
|
|
32
|
-
* @param
|
|
34
|
+
* @param userId
|
|
33
35
|
* @returns
|
|
34
36
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
getUserFrame(userId: string, username: string, avatarUrl: string | null): Promise<Buffer<ArrayBuffer>>;
|
|
38
|
+
getFrameConfig(): Promise<FrameConfigElement[]>;
|
|
37
39
|
/**
|
|
38
40
|
* Gets frame image
|
|
39
41
|
*/
|
|
40
|
-
|
|
42
|
+
getFrame(frameId: string): Promise<Buffer<ArrayBuffer>>;
|
|
41
43
|
/**
|
|
42
|
-
* Get users
|
|
43
|
-
* @param user_id
|
|
44
|
-
* @returns
|
|
44
|
+
* Get all Minecraft users linked to Discord accounts
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
getAllMinecraftUsers(): Promise<MinecraftData[]>;
|
|
47
|
+
private fetchData;
|
|
48
|
+
}
|
|
49
|
+
interface FrameConfigElement {
|
|
50
|
+
name: string;
|
|
51
|
+
id: number;
|
|
52
|
+
path: string;
|
|
53
|
+
frameLink: string;
|
|
54
|
+
}
|
|
55
|
+
interface UserFrameData {
|
|
56
|
+
frameId: number;
|
|
57
|
+
hexColor: string;
|
|
58
|
+
xpPercentage: number;
|
|
59
|
+
xp: number;
|
|
60
|
+
level: number;
|
|
61
|
+
cachedId: string;
|
|
47
62
|
}
|
|
63
|
+
export {};
|
package/dist/classes/models.js
CHANGED
|
@@ -1,106 +1,130 @@
|
|
|
1
1
|
import { ConfigData } from "./ConfigData.js";
|
|
2
2
|
import { GamerBotAPI } from "./gamerbot.js";
|
|
3
3
|
import { GuildData } from "./GuildData.js";
|
|
4
|
-
import {
|
|
4
|
+
import { UserData } from "./UserData.js";
|
|
5
5
|
export class Models {
|
|
6
|
-
constructor() {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.cachedUsersFrames = new Map();
|
|
8
|
+
}
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param
|
|
10
|
+
* Get user data
|
|
11
|
+
* @param userId discord user id
|
|
10
12
|
* @returns
|
|
11
13
|
*/
|
|
12
|
-
async
|
|
13
|
-
const data = await this.
|
|
14
|
-
const
|
|
15
|
-
return
|
|
14
|
+
async getUserData(userId) {
|
|
15
|
+
const data = await this.fetchData(GamerBotAPI.API_URL + "/api/user/" + userId);
|
|
16
|
+
const userData = new UserData(data);
|
|
17
|
+
return userData;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
20
|
+
* Get multiple users data
|
|
21
|
+
* @param maxUsers amount of users to fetch
|
|
20
22
|
* @returns
|
|
21
23
|
*/
|
|
22
|
-
async
|
|
23
|
-
const data = (await this.
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
profile_data.push(new PorfileData(element));
|
|
28
|
-
});
|
|
29
|
-
return profile_data;
|
|
24
|
+
async getAllUserData(maxUsers, filter = {}) {
|
|
25
|
+
const data = (await this.fetchData(GamerBotAPI.API_URL + "/api/user/fetch_many", "POST", { maxUsers: maxUsers, filter: filter }));
|
|
26
|
+
const userData = [];
|
|
27
|
+
data.forEach((element) => userData.push(new UserData(element)));
|
|
28
|
+
return userData;
|
|
30
29
|
}
|
|
31
30
|
/**
|
|
32
|
-
*
|
|
31
|
+
* Get config data
|
|
33
32
|
* @param id config id
|
|
34
33
|
* @returns
|
|
35
34
|
*/
|
|
36
|
-
async
|
|
37
|
-
const data = await this.
|
|
38
|
-
const
|
|
39
|
-
return
|
|
35
|
+
async getConfigData(id) {
|
|
36
|
+
const data = await this.fetchData(GamerBotAPI.API_URL + "/api/config/" + id);
|
|
37
|
+
const configData = new ConfigData(data);
|
|
38
|
+
return configData;
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param
|
|
41
|
+
* Get guild data
|
|
42
|
+
* @param guildId discord guild id
|
|
44
43
|
* @returns
|
|
45
44
|
*/
|
|
46
|
-
async
|
|
47
|
-
const data = await this.
|
|
45
|
+
async getGuildData(guildId) {
|
|
46
|
+
const data = await this.fetchData(GamerBotAPI.API_URL + "/api/guild/" + guildId);
|
|
48
47
|
return new GuildData(data);
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
51
50
|
* Get users frame
|
|
52
|
-
* @param
|
|
51
|
+
* @param userId
|
|
53
52
|
* @returns
|
|
54
53
|
*/
|
|
55
|
-
async
|
|
56
|
-
const
|
|
57
|
-
let xpPercentage
|
|
54
|
+
async getUserFrame(userId, username, avatarUrl) {
|
|
55
|
+
const userData = await this.getUserData(userId);
|
|
56
|
+
let xpPercentage;
|
|
57
|
+
if (userData.levelSystem.level == 0) {
|
|
58
|
+
xpPercentage = Math.round((userData.levelSystem.xp / (userData.levelSystem.level + 1) ** 2) * 100);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
xpPercentage = Math.round((userData.levelSystem.xp / userData.levelSystem.level ** 2) * 100);
|
|
62
|
+
}
|
|
58
63
|
// Progressbar is constant after lvl 31
|
|
59
|
-
if (
|
|
60
|
-
xpPercentage = Math.round((
|
|
64
|
+
if (userData.levelSystem.level > 31) {
|
|
65
|
+
xpPercentage = Math.round((userData.levelSystem.xp / 961) * 100);
|
|
66
|
+
}
|
|
67
|
+
if (!userData.frameData.frameColorHexCode)
|
|
68
|
+
userData.frameData.frameColorHexCode = "#000000";
|
|
69
|
+
let cachedFrame = null;
|
|
70
|
+
if (this.cachedUsersFrames.has(userId)) {
|
|
71
|
+
cachedFrame = this.cachedUsersFrames.get(userId);
|
|
72
|
+
if (cachedFrame.xp != userData.levelSystem.xp ||
|
|
73
|
+
cachedFrame.level != userData.levelSystem.level ||
|
|
74
|
+
cachedFrame.hexColor != userData.frameData.frameColorHexCode ||
|
|
75
|
+
cachedFrame.frameId != userData.frameData.selectedFrame) {
|
|
76
|
+
cachedFrame = null;
|
|
77
|
+
this.cachedUsersFrames.delete(userId);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (cachedFrame == null) {
|
|
81
|
+
cachedFrame = {
|
|
82
|
+
frameId: userData.frameData.selectedFrame,
|
|
83
|
+
hexColor: userData.frameData.frameColorHexCode,
|
|
84
|
+
xpPercentage: xpPercentage,
|
|
85
|
+
xp: userData.levelSystem.xp,
|
|
86
|
+
level: userData.levelSystem.level,
|
|
87
|
+
cachedId: Math.random().toString(36).substring(2, 15),
|
|
88
|
+
};
|
|
89
|
+
this.cachedUsersFrames.set(userId, cachedFrame);
|
|
61
90
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
xp_percentage: xpPercentage,
|
|
71
|
-
avatar_url: avatar_url,
|
|
72
|
-
force: force,
|
|
91
|
+
const data = (await this.fetchData(GamerBotAPI.API_URL + "/public_api/frame/generate", "POST", {
|
|
92
|
+
name: username,
|
|
93
|
+
frameId: cachedFrame.frameId,
|
|
94
|
+
hexColor: cachedFrame.hexColor,
|
|
95
|
+
level: cachedFrame.level,
|
|
96
|
+
xpPercentage: cachedFrame.xpPercentage,
|
|
97
|
+
memberAvatar: avatarUrl,
|
|
98
|
+
cachedId: cachedFrame.cachedId,
|
|
73
99
|
}, false));
|
|
74
100
|
return Buffer.from(await data.arrayBuffer());
|
|
75
101
|
}
|
|
76
|
-
async
|
|
77
|
-
const data = await this.
|
|
78
|
-
return data;
|
|
102
|
+
async getFrameConfig() {
|
|
103
|
+
const data = await this.fetchData(GamerBotAPI.API_URL + "/public_api/frame/config");
|
|
104
|
+
return data.frames;
|
|
79
105
|
}
|
|
80
106
|
/**
|
|
81
107
|
* Gets frame image
|
|
82
108
|
*/
|
|
83
|
-
async
|
|
84
|
-
const data = (await this.
|
|
85
|
-
"/public_api/frame/get/" +
|
|
86
|
-
guild_id +
|
|
87
|
-
"/" +
|
|
88
|
-
frame_id, "GET", null, false));
|
|
109
|
+
async getFrame(frameId) {
|
|
110
|
+
const data = (await this.fetchData(GamerBotAPI.API_URL + "/public_api/frame/" + frameId, "GET", null, false));
|
|
89
111
|
return Buffer.from(await data.arrayBuffer());
|
|
90
112
|
}
|
|
91
113
|
/**
|
|
92
|
-
* Get users
|
|
93
|
-
* @param user_id
|
|
94
|
-
* @returns
|
|
114
|
+
* Get all Minecraft users linked to Discord accounts
|
|
95
115
|
*/
|
|
96
|
-
|
|
116
|
+
async getAllMinecraftUsers() {
|
|
117
|
+
const data = await this.fetchData(GamerBotAPI.API_URL + "/api/user/minecraft/data/", "GET");
|
|
118
|
+
return data;
|
|
119
|
+
}
|
|
120
|
+
fetchData(url, method = "GET",
|
|
97
121
|
// eslint-disable-next-line
|
|
98
|
-
|
|
99
|
-
|
|
122
|
+
jsonData = null, convertToJson = true) {
|
|
123
|
+
jsonData = jsonData ? JSON.stringify(jsonData) : null;
|
|
100
124
|
return new Promise((resolve, reject) => {
|
|
101
125
|
fetch(url, {
|
|
102
126
|
method: method,
|
|
103
|
-
body:
|
|
127
|
+
body: jsonData,
|
|
104
128
|
headers: {
|
|
105
129
|
"Content-Type": "application/json",
|
|
106
130
|
authorization: "Bearer " + GamerBotAPI.TOKEN,
|
|
@@ -112,7 +136,7 @@ export class Models {
|
|
|
112
136
|
console.error("Error fetching data: ", error);
|
|
113
137
|
reject(error);
|
|
114
138
|
}
|
|
115
|
-
if (!
|
|
139
|
+
if (!convertToJson)
|
|
116
140
|
return response;
|
|
117
141
|
else
|
|
118
142
|
return response.json();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { GamerBotAPI } from "./classes/gamerbot.js";
|
|
2
|
-
export {
|
|
2
|
+
export { UserData, Reminder } from "./classes/UserData.js";
|
|
3
3
|
export { GuildData } from "./classes/GuildData.js";
|
|
4
4
|
export { ConfigData } from "./classes/ConfigData.js";
|
|
5
5
|
export { Models } from "./classes/models.js";
|
|
6
|
+
export { Level } from "./classes/ConfigData.js";
|
|
7
|
+
export { MinecraftData } from "./classes/MinecraftData.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { GamerBotAPI } from "./classes/gamerbot.js";
|
|
2
|
-
export {
|
|
2
|
+
export { UserData } from "./classes/UserData.js";
|
|
3
3
|
export { GuildData } from "./classes/GuildData.js";
|
|
4
4
|
export { ConfigData } from "./classes/ConfigData.js";
|
|
5
5
|
export { Models } from "./classes/models.js";
|
|
6
|
+
export { MinecraftData } from "./classes/MinecraftData.js";
|
package/package.json
CHANGED
|
@@ -1,32 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gamerbot-module",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"files": [
|
|
9
|
-
"
|
|
9
|
+
"dist"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
13
|
"link": "tsc -p tsconfig.json && npm link",
|
|
14
|
-
"
|
|
14
|
+
"prebuild": "rm -rf dist",
|
|
15
|
+
"build": "npm run prebuild && tsc -p tsconfig.json",
|
|
16
|
+
"prepare": "npm run build"
|
|
15
17
|
},
|
|
16
18
|
"author": "lukasabbe",
|
|
17
19
|
"license": "MIT",
|
|
18
20
|
"devDependencies": {
|
|
19
|
-
"@eslint/js": "^9.
|
|
20
|
-
"@types/node": "^
|
|
21
|
-
"concurrently": "^
|
|
22
|
-
"eslint": "^9.
|
|
23
|
-
"globals": "^
|
|
24
|
-
"nodemon": "^3.1.
|
|
21
|
+
"@eslint/js": "^9.39.1",
|
|
22
|
+
"@types/node": "^24.10.1",
|
|
23
|
+
"concurrently": "^9.2.1",
|
|
24
|
+
"eslint": "^9.39.1",
|
|
25
|
+
"globals": "^16.5.0",
|
|
26
|
+
"nodemon": "^3.1.11",
|
|
25
27
|
"ts-node": "^10.9.2",
|
|
26
|
-
"typescript": "^5.
|
|
27
|
-
"typescript-eslint": "^8.
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"typescript-eslint": "^8.48.0"
|
|
28
30
|
},
|
|
29
31
|
"dependencies": {
|
|
30
|
-
"dotenv": "^
|
|
32
|
+
"dotenv": "^17.2.3"
|
|
33
|
+
}
|
|
34
|
+
,
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/onlinesgc/Gamerbot-module.git"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/onlinesgc/Gamerbot-module/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/onlinesgc/Gamerbot-module#readme",
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=16"
|
|
45
|
+
},
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"import": "./dist/index.js"
|
|
49
|
+
}
|
|
31
50
|
}
|
|
32
51
|
}
|
|
@@ -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,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
|
-
}
|
|
@@ -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
|
-
}
|