@duque.edits/sdk 0.2.1 → 0.2.21
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/managers/logs/LogManager.js +25 -17
- package/dist/rest/Routes.js +3 -3
- package/dist/structures/index.js +1 -0
- package/dist/structures/logentry/LogEntry.js +68 -0
- package/dist/structures/user/GuildUser.js +4 -1
- package/dist/types/api/APILogEntry.js +11 -0
- package/package.json +1 -1
- package/types/managers/logs/LogManager.d.ts +5 -6
- package/types/rest/Routes.d.ts +1 -1
- package/types/structures/index.d.ts +1 -0
- package/types/structures/logentry/LogEntry.d.ts +28 -0
- package/types/types/RestTypes.d.ts +2 -0
- package/types/types/api/APIGuild.d.ts +1 -0
- package/types/types/api/APIGuildUser.d.ts +3 -0
- package/types/types/api/APILogEntry.d.ts +15 -2
|
@@ -18,7 +18,7 @@ class LogManager extends base_1.BaseManager {
|
|
|
18
18
|
method: "GET",
|
|
19
19
|
url: route,
|
|
20
20
|
});
|
|
21
|
-
return response;
|
|
21
|
+
return this.set(response);
|
|
22
22
|
}
|
|
23
23
|
async create(data) {
|
|
24
24
|
const route = this.base_url;
|
|
@@ -28,32 +28,40 @@ class LogManager extends base_1.BaseManager {
|
|
|
28
28
|
url: route,
|
|
29
29
|
payload,
|
|
30
30
|
});
|
|
31
|
-
this.set(response);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const route = this.base_url;
|
|
36
|
-
const payload = { ...data };
|
|
37
|
-
const response = await this.rest.request({
|
|
38
|
-
method: "POST",
|
|
39
|
-
url: route,
|
|
40
|
-
payload,
|
|
41
|
-
});
|
|
42
|
-
this.set(response);
|
|
43
|
-
return response;
|
|
31
|
+
const logEntry = this.set(response);
|
|
32
|
+
this.cache.set(data._id, logEntry);
|
|
33
|
+
this.rest.emit("logEntryCreate", logEntry, this.guild);
|
|
34
|
+
return logEntry;
|
|
44
35
|
}
|
|
36
|
+
/* async createMany(data: Optional<APILogEntry>[]): Promise<APILogEntry[]> {
|
|
37
|
+
const route = Routes.fields(this.base_url, "bulk");
|
|
38
|
+
const payload = { ...data };
|
|
39
|
+
const response = await this.rest.request<APILogEntry[], typeof payload>({
|
|
40
|
+
method: "POST",
|
|
41
|
+
url: route,
|
|
42
|
+
payload,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.set(response);
|
|
46
|
+
return response;
|
|
47
|
+
} */
|
|
45
48
|
set(data) {
|
|
46
49
|
if (!data)
|
|
47
50
|
return this.cache;
|
|
48
51
|
if (Array.isArray(data)) {
|
|
52
|
+
this.cache.clear();
|
|
49
53
|
for (let entry of data) {
|
|
50
|
-
|
|
54
|
+
if (!entry._id)
|
|
55
|
+
continue;
|
|
56
|
+
const logEntry = new structures_1.LogEntry(entry, this);
|
|
57
|
+
this.cache.set(entry._id, logEntry);
|
|
51
58
|
}
|
|
52
59
|
return this.cache;
|
|
53
60
|
}
|
|
54
61
|
else {
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
const logEntry = new structures_1.LogEntry(data, this);
|
|
63
|
+
this.cache.set(data._id, logEntry);
|
|
64
|
+
return logEntry;
|
|
57
65
|
}
|
|
58
66
|
}
|
|
59
67
|
}
|
package/dist/rest/Routes.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Routes = void 0;
|
|
4
4
|
exports.Routes = {
|
|
5
|
-
|
|
6
|
-
base:
|
|
5
|
+
base: "http://localhost:80/api/v1",
|
|
6
|
+
//base: "https://dpqd.shardweb.app/api/v1",
|
|
7
7
|
field: (field) => `/${field}`,
|
|
8
8
|
fields: (...fields) => `${fields.join("/")}`,
|
|
9
9
|
guilds: {
|
|
@@ -13,7 +13,7 @@ exports.Routes = {
|
|
|
13
13
|
delete: (guildId) => `/guilds/${guildId}`,
|
|
14
14
|
deleteAll: () => `/guilds`,
|
|
15
15
|
resource: (guildId, resource) => `/guilds/${guildId}/manage/${resource}`,
|
|
16
|
-
resources: (guildId, ...
|
|
16
|
+
resources: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
|
|
17
17
|
users: {
|
|
18
18
|
create: (guildId) => `/guilds/${guildId}/users`,
|
|
19
19
|
update: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
package/dist/structures/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./guild/Guild"), exports);
|
|
18
|
+
__exportStar(require("./logentry/LogEntry"), exports);
|
|
18
19
|
__exportStar(require("./match/GuildMatch"), exports);
|
|
19
20
|
__exportStar(require("./user/GuildUser"), exports);
|
|
20
21
|
__exportStar(require("./vipmember/VipMember"), exports);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogEntry = void 0;
|
|
4
|
+
const rest_1 = require("../../rest");
|
|
5
|
+
class LogEntry {
|
|
6
|
+
_id;
|
|
7
|
+
guild_id;
|
|
8
|
+
user_id;
|
|
9
|
+
admin_id;
|
|
10
|
+
object_id;
|
|
11
|
+
type;
|
|
12
|
+
description;
|
|
13
|
+
change;
|
|
14
|
+
before;
|
|
15
|
+
after;
|
|
16
|
+
logs_channel_id;
|
|
17
|
+
createdAt;
|
|
18
|
+
updatedAt;
|
|
19
|
+
manager;
|
|
20
|
+
/** The given guild */
|
|
21
|
+
guild;
|
|
22
|
+
/** The rest client */
|
|
23
|
+
rest;
|
|
24
|
+
constructor(data, manager) {
|
|
25
|
+
this.manager = manager;
|
|
26
|
+
this.guild = manager.guild;
|
|
27
|
+
this._id = data?._id;
|
|
28
|
+
this.guild_id = data?.guild_id;
|
|
29
|
+
this.user_id = data?.user_id;
|
|
30
|
+
this.admin_id = data?.admin_id;
|
|
31
|
+
this.object_id = data?.object_id;
|
|
32
|
+
this.type = data?.type;
|
|
33
|
+
this.description = data?.description;
|
|
34
|
+
this.change = data?.change;
|
|
35
|
+
this.before = data?.before;
|
|
36
|
+
this.after = data?.after;
|
|
37
|
+
this.logs_channel_id = data?.logs_channel_id;
|
|
38
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
39
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
40
|
+
}
|
|
41
|
+
async fetch() {
|
|
42
|
+
const route = rest_1.Routes.guilds.resources(this.guild.id, "logs", this._id);
|
|
43
|
+
const response = await this.rest.request({ url: route, method: "GET" });
|
|
44
|
+
return this._updateInternals(response);
|
|
45
|
+
}
|
|
46
|
+
toJSON() {
|
|
47
|
+
const json = {};
|
|
48
|
+
for (const [key, value] of Object.entries(this)) {
|
|
49
|
+
if (typeof value !== "function") {
|
|
50
|
+
json[key] = value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return json;
|
|
54
|
+
}
|
|
55
|
+
_updateInternals(data) {
|
|
56
|
+
for (let key in data) {
|
|
57
|
+
if (key === "id" || key === "createdAt")
|
|
58
|
+
continue;
|
|
59
|
+
if (key in this) {
|
|
60
|
+
this[key] = data[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this.updatedAt = new Date();
|
|
64
|
+
this.manager.cache.set(this._id, this);
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.LogEntry = LogEntry;
|
|
@@ -149,8 +149,11 @@ class GuildUser {
|
|
|
149
149
|
profile: {
|
|
150
150
|
avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
|
|
151
151
|
bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
|
|
152
|
-
bio: data.bio || this.profile.bio || "",
|
|
152
|
+
bio: data.bio || this.profile.bio || "Melhor da minha aldeia (use !bio para alterar)",
|
|
153
153
|
name: data.name || this.profile.name || "",
|
|
154
|
+
textColor: data.textColor || this.profile.textColor || "#ffffff",
|
|
155
|
+
primaryColor: data.primaryColor || this.profile.primaryColor || "#272727",
|
|
156
|
+
secondaryColor: data.secondaryColor || this.profile.secondaryColor || "#151515",
|
|
154
157
|
},
|
|
155
158
|
};
|
|
156
159
|
const route = Routes_1.Routes.guilds.users.update(this.manager.guild.id, this.id);
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogEntryTypes = void 0;
|
|
4
|
+
var LogEntryTypes;
|
|
5
|
+
(function (LogEntryTypes) {
|
|
6
|
+
LogEntryTypes["QueueCreated"] = "queue_created";
|
|
7
|
+
LogEntryTypes["QueueShut"] = "queue_shut";
|
|
8
|
+
LogEntryTypes["MatchStarted"] = "match_started";
|
|
9
|
+
LogEntryTypes["MatchUpdated"] = "match_updated";
|
|
10
|
+
LogEntryTypes["MatchClosed"] = "match_closed";
|
|
11
|
+
LogEntryTypes["UserUpdated"] = "user_updated";
|
|
12
|
+
LogEntryTypes["UserManaged"] = "user_managed";
|
|
13
|
+
})(LogEntryTypes || (exports.LogEntryTypes = LogEntryTypes = {}));
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Collection, Guild } from "../../structures";
|
|
1
|
+
import { Collection, Guild, LogEntry } from "../../structures";
|
|
2
2
|
import { Optional } from "../../types";
|
|
3
3
|
import { APILogEntry } from "../../types/api/APILogEntry";
|
|
4
4
|
import { BaseManager } from "../base";
|
|
5
|
-
export declare class LogManager extends BaseManager<
|
|
5
|
+
export declare class LogManager extends BaseManager<LogEntry> {
|
|
6
6
|
constructor(guild: Guild);
|
|
7
|
-
fetch(): Promise<
|
|
8
|
-
create(data: Optional<APILogEntry>): Promise<
|
|
9
|
-
|
|
10
|
-
set(data: APILogEntry | APILogEntry[]): APILogEntry | Collection<string, APILogEntry>;
|
|
7
|
+
fetch(): Promise<Collection<string, LogEntry>>;
|
|
8
|
+
create(data: Optional<APILogEntry>): Promise<LogEntry>;
|
|
9
|
+
set(data: APILogEntry | APILogEntry[]): LogEntry | Collection<string, LogEntry>;
|
|
11
10
|
}
|
package/types/rest/Routes.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const Routes: {
|
|
|
10
10
|
delete: (guildId: string) => string;
|
|
11
11
|
deleteAll: () => string;
|
|
12
12
|
resource: (guildId: string, resource: string) => string;
|
|
13
|
-
resources: (guildId: string, ...
|
|
13
|
+
resources: (guildId: string, ...resources: string[]) => string;
|
|
14
14
|
users: {
|
|
15
15
|
create: (guildId: string) => string;
|
|
16
16
|
update: (guildId: string, userId: string) => string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LogManager } from "../../managers";
|
|
2
|
+
import { REST } from "../../rest";
|
|
3
|
+
import { APILogEntry, LogEntryTypes, Optional } from "../../types";
|
|
4
|
+
import { Guild } from "../guild/Guild";
|
|
5
|
+
export declare class LogEntry {
|
|
6
|
+
_id: string;
|
|
7
|
+
guild_id: string;
|
|
8
|
+
user_id: string;
|
|
9
|
+
admin_id: string;
|
|
10
|
+
object_id: string;
|
|
11
|
+
type: LogEntryTypes;
|
|
12
|
+
description: string;
|
|
13
|
+
change: string;
|
|
14
|
+
before: any;
|
|
15
|
+
after: any;
|
|
16
|
+
logs_channel_id: string;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
manager: LogManager;
|
|
20
|
+
/** The given guild */
|
|
21
|
+
readonly guild: Guild;
|
|
22
|
+
/** The rest client */
|
|
23
|
+
readonly rest: REST;
|
|
24
|
+
constructor(data: APILogEntry, manager: LogManager);
|
|
25
|
+
fetch(): Promise<LogEntry>;
|
|
26
|
+
toJSON(): Record<string, unknown>;
|
|
27
|
+
_updateInternals(data: Optional<APILogEntry>): this;
|
|
28
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogEntry } from "../structures";
|
|
1
2
|
import { Collection } from "../structures/Collection";
|
|
2
3
|
import { Guild } from "../structures/guild/Guild";
|
|
3
4
|
import { GuildMatch } from "../structures/match/GuildMatch";
|
|
@@ -31,4 +32,5 @@ export interface RestEvents {
|
|
|
31
32
|
userDelete: [GuildUser];
|
|
32
33
|
userUpdate: [GuildUser];
|
|
33
34
|
usersDelete: [Collection<string, GuildUser>];
|
|
35
|
+
logEntryCreate: [LogEntry, Guild];
|
|
34
36
|
}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
+
export declare enum LogEntryTypes {
|
|
2
|
+
QueueCreated = "queue_created",
|
|
3
|
+
QueueShut = "queue_shut",
|
|
4
|
+
MatchStarted = "match_started",
|
|
5
|
+
MatchUpdated = "match_updated",
|
|
6
|
+
MatchClosed = "match_closed",
|
|
7
|
+
UserUpdated = "user_updated",
|
|
8
|
+
UserManaged = "user_managed"
|
|
9
|
+
}
|
|
1
10
|
export interface APILogEntry {
|
|
2
11
|
_id: string;
|
|
3
12
|
guild_id: string;
|
|
4
|
-
type: string;
|
|
5
13
|
user_id: string;
|
|
14
|
+
admin_id: string;
|
|
15
|
+
object_id: string;
|
|
16
|
+
type: LogEntryTypes;
|
|
6
17
|
description: string;
|
|
7
18
|
change: string;
|
|
8
|
-
|
|
19
|
+
logs_channel_id: string;
|
|
20
|
+
before: any;
|
|
21
|
+
after: any;
|
|
9
22
|
createdAt: Date;
|
|
10
23
|
updatedAt: Date;
|
|
11
24
|
}
|