@duque.edits/sdk 0.0.3 → 0.0.5
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/{src/index.ts → dist/index.d.ts} +27 -30
- package/dist/index.js +43 -0
- package/dist/managers/bet/GuildBetManager.d.ts +32 -0
- package/dist/managers/bet/GuildBetManager.js +107 -0
- package/dist/managers/betuser/GuildBetUserManager.d.ts +30 -0
- package/dist/managers/betuser/GuildBetUserManager.js +94 -0
- package/dist/managers/channel/ChannelManager.d.ts +39 -0
- package/dist/managers/channel/ChannelManager.js +147 -0
- package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +34 -0
- package/dist/managers/groupedchannel/GroupedChannelManager.js +92 -0
- package/dist/managers/guild/GuildManager.d.ts +24 -0
- package/dist/managers/guild/GuildManager.js +75 -0
- package/dist/managers/match/GuildMatchManager.d.ts +32 -0
- package/dist/managers/match/GuildMatchManager.js +103 -0
- package/dist/managers/mediator/GuildMediatorManager.d.ts +32 -0
- package/dist/managers/mediator/GuildMediatorManager.js +97 -0
- package/dist/managers/messages/MessagesManager.d.ts +32 -0
- package/dist/managers/messages/MessagesManager.js +82 -0
- package/dist/managers/permission/GuildPermissionManager.d.ts +26 -0
- package/dist/managers/permission/GuildPermissionManager.js +70 -0
- package/dist/managers/product/GuildProductManager.d.ts +32 -0
- package/dist/managers/product/GuildProductManager.js +102 -0
- package/dist/managers/ticket/GuildTicketManager.d.ts +32 -0
- package/dist/managers/ticket/GuildTicketManager.js +99 -0
- package/dist/managers/user/GuildUserManager.d.ts +32 -0
- package/dist/managers/user/GuildUserManager.js +106 -0
- package/dist/rest/APIEndpoints.d.ts +11 -0
- package/dist/rest/APIEndpoints.js +12 -0
- package/dist/rest/REST.d.ts +51 -0
- package/dist/rest/REST.js +96 -0
- package/dist/rest/Routes.d.ts +84 -0
- package/dist/rest/Routes.js +89 -0
- package/dist/structures/Collection.d.ts +17 -0
- package/dist/structures/Collection.js +87 -0
- package/dist/structures/bet/GuildBet.d.ts +86 -0
- package/dist/structures/bet/GuildBet.js +276 -0
- package/dist/structures/betuser/GuildBetUser.d.ts +82 -0
- package/dist/structures/betuser/GuildBetUser.js +194 -0
- package/dist/structures/channel/Channel.d.ts +31 -0
- package/dist/structures/channel/Channel.js +57 -0
- package/dist/structures/groupedchannel/GroupedChannel.d.ts +34 -0
- package/dist/structures/groupedchannel/GroupedChannel.js +121 -0
- package/dist/structures/guild/Guild.d.ts +89 -0
- package/dist/structures/guild/Guild.js +223 -0
- package/dist/structures/match/GuildMatch.d.ts +84 -0
- package/dist/structures/match/GuildMatch.js +327 -0
- package/dist/structures/mediator/GuildMediator.d.ts +41 -0
- package/dist/structures/mediator/GuildMediator.js +131 -0
- package/dist/structures/product/GuildProduct.d.ts +52 -0
- package/dist/structures/product/GuildProduct.js +175 -0
- package/dist/structures/shop/GuildShop.d.ts +34 -0
- package/dist/structures/shop/GuildShop.js +80 -0
- package/dist/structures/ticket/GuildTicket.d.ts +51 -0
- package/dist/structures/ticket/GuildTicket.js +170 -0
- package/dist/structures/user/GuildUser.d.ts +82 -0
- package/dist/structures/user/GuildUser.js +209 -0
- package/dist/types/api/APIBaseChannel.d.ts +10 -0
- package/dist/types/api/APIBaseChannel.js +2 -0
- package/dist/types/api/APIBetChannel.d.ts +10 -0
- package/dist/types/api/APIBetChannel.js +2 -0
- package/dist/types/api/APIBetMessage.d.ts +10 -0
- package/dist/types/api/APIBetMessage.js +2 -0
- package/dist/types/api/APIGuild.d.ts +92 -0
- package/dist/types/api/APIGuild.js +2 -0
- package/dist/types/api/APIGuildBet.d.ts +48 -0
- package/dist/types/api/APIGuildBet.js +2 -0
- package/dist/types/api/APIGuildBetUser.d.ts +32 -0
- package/dist/types/api/APIGuildBetUser.js +2 -0
- package/dist/types/api/APIGuildChannel.d.ts +10 -0
- package/dist/types/api/APIGuildChannel.js +2 -0
- package/dist/types/api/APIGuildEmoji.d.ts +12 -0
- package/dist/types/api/APIGuildEmoji.js +2 -0
- package/dist/types/api/APIGuildGroupedChannel.d.ts +10 -0
- package/dist/types/api/APIGuildGroupedChannel.js +2 -0
- package/dist/types/api/APIGuildMatch.d.ts +46 -0
- package/dist/types/api/APIGuildMatch.js +2 -0
- package/dist/types/api/APIGuildMediator.d.ts +13 -0
- package/dist/types/api/APIGuildMediator.js +3 -0
- package/dist/types/api/APIGuildMessage.d.ts +10 -0
- package/dist/types/api/APIGuildMessage.js +2 -0
- package/dist/types/api/APIGuildPermissions.d.ts +6 -0
- package/dist/types/api/APIGuildPermissions.js +2 -0
- package/dist/types/api/APIGuildRole.d.ts +10 -0
- package/dist/types/api/APIGuildRole.js +2 -0
- package/dist/types/api/APIGuildShop.d.ts +11 -0
- package/dist/types/api/APIGuildShop.js +2 -0
- package/dist/types/api/APIGuildTicket.d.ts +25 -0
- package/dist/types/api/APIGuildTicket.js +3 -0
- package/dist/types/api/APIGuildUser.d.ts +31 -0
- package/dist/types/api/APIGuildUser.js +2 -0
- package/dist/types/api/APIMessage.d.ts +12 -0
- package/dist/types/api/APIMessage.js +2 -0
- package/dist/types/api/APIPlayer.d.ts +10 -0
- package/dist/types/api/APIPlayer.js +2 -0
- package/dist/types/api/APIProduct.d.ts +19 -0
- package/dist/types/api/APIProduct.js +3 -0
- package/dist/types/api/index.d.ts +130 -0
- package/dist/types/api/index.js +35 -0
- package/{src/types/index.ts → dist/types/index.d.ts} +21 -24
- package/dist/types/index.js +37 -0
- package/dist/utils/Assertion.d.ts +32 -0
- package/dist/utils/Assertion.js +60 -0
- package/package.json +5 -1
- package/.gitattributes +0 -2
- package/src/managers/bet/GuildBetManager.ts +0 -117
- package/src/managers/betuser/GuildBetUserManager.ts +0 -103
- package/src/managers/channel/ChannelManager.ts +0 -168
- package/src/managers/groupedchannel/GroupedChannelManager.ts +0 -117
- package/src/managers/guild/GuildManager.ts +0 -84
- package/src/managers/match/GuildMatchManager.ts +0 -115
- package/src/managers/mediator/GuildMediatorManager.ts +0 -111
- package/src/managers/messages/MessagesManager.ts +0 -95
- package/src/managers/permission/GuildPermissionManager.ts +0 -88
- package/src/managers/product/GuildProductManager.ts +0 -115
- package/src/managers/ticket/GuildTicketManager.ts +0 -112
- package/src/managers/user/GuildUserManager.ts +0 -116
- package/src/rest/APIEndpoints.ts +0 -11
- package/src/rest/REST.ts +0 -126
- package/src/rest/Routes.ts +0 -143
- package/src/structures/Collection.ts +0 -85
- package/src/structures/bet/GuildBet.ts +0 -332
- package/src/structures/betuser/GuildBetUser.ts +0 -247
- package/src/structures/channel/Channel.ts +0 -78
- package/src/structures/groupedchannel/GroupedChannel.ts +0 -165
- package/src/structures/guild/Guild.ts +0 -302
- package/src/structures/match/GuildMatch.ts +0 -385
- package/src/structures/mediator/GuildMediator.ts +0 -175
- package/src/structures/product/GuildProduct.ts +0 -217
- package/src/structures/shop/GuildShop.ts +0 -98
- package/src/structures/ticket/GuildTicket.ts +0 -227
- package/src/structures/user/GuildUser.ts +0 -248
- package/src/types/api/APIBaseChannel.ts +0 -13
- package/src/types/api/APIBetChannel.ts +0 -13
- package/src/types/api/APIBetMessage.ts +0 -13
- package/src/types/api/APIGuild.ts +0 -123
- package/src/types/api/APIGuildBet.ts +0 -69
- package/src/types/api/APIGuildBetUser.ts +0 -46
- package/src/types/api/APIGuildChannel.ts +0 -13
- package/src/types/api/APIGuildEmoji.ts +0 -16
- package/src/types/api/APIGuildGroupedChannel.ts +0 -13
- package/src/types/api/APIGuildMatch.ts +0 -67
- package/src/types/api/APIGuildMediator.ts +0 -18
- package/src/types/api/APIGuildMessage.ts +0 -13
- package/src/types/api/APIGuildPermissions.ts +0 -7
- package/src/types/api/APIGuildRole.ts +0 -13
- package/src/types/api/APIGuildShop.ts +0 -15
- package/src/types/api/APIGuildTicket.ts +0 -36
- package/src/types/api/APIGuildUser.ts +0 -45
- package/src/types/api/APIMessage.ts +0 -16
- package/src/types/api/APIPlayer.ts +0 -13
- package/src/types/api/APIProduct.ts +0 -27
- package/src/types/api/index.ts +0 -180
- package/src/utils/Assertion.ts +0 -56
- package/src/v1/managers/channel/ChannelManager.ts +0 -167
- package/src/v1/managers/match/GuildMatchManager.ts +0 -114
- package/tests/index.ts +0 -86
- package/tsconfig.json +0 -15
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { APIProduct } from "./APIProduct";
|
|
2
|
+
export interface APIGuildShop {
|
|
3
|
+
/** Shop's product */
|
|
4
|
+
products: APIProduct[];
|
|
5
|
+
/** Bought count */
|
|
6
|
+
boughtCount: number;
|
|
7
|
+
/** Creation Date */
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
/** Updated Date */
|
|
10
|
+
updatedAt: Date;
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { APIMessage } from "./APIMessage";
|
|
2
|
+
export interface APIGuildTicket {
|
|
3
|
+
/** Ticket's id */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Ticket's creator id */
|
|
6
|
+
creatorId: string;
|
|
7
|
+
/** Ticket's admin id */
|
|
8
|
+
adminId: string;
|
|
9
|
+
/** Ticket's rating that customer gave */
|
|
10
|
+
customerRating: number;
|
|
11
|
+
/** Ticket's channel id */
|
|
12
|
+
channelId: string;
|
|
13
|
+
/** Ticket's closed by who */
|
|
14
|
+
closedById: string;
|
|
15
|
+
/** Ticket's type */
|
|
16
|
+
type: string;
|
|
17
|
+
/** Ticket's status */
|
|
18
|
+
status: "on" | "off";
|
|
19
|
+
/** Ticket's messages */
|
|
20
|
+
messages: APIMessage[];
|
|
21
|
+
/** Creation Date */
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
/** Updated Date */
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Accessory, Daily, Items, OriginalChannels } from ".";
|
|
2
|
+
export interface APIGuildUser {
|
|
3
|
+
/** User's id */
|
|
4
|
+
id: string;
|
|
5
|
+
/** User name */
|
|
6
|
+
name: string;
|
|
7
|
+
/** User's daily */
|
|
8
|
+
daily: Omit<Daily, "credit">;
|
|
9
|
+
/** User's points */
|
|
10
|
+
points: number;
|
|
11
|
+
/** User's wins */
|
|
12
|
+
wins: number;
|
|
13
|
+
/** User's mvps */
|
|
14
|
+
mvps: number;
|
|
15
|
+
/** User's losses */
|
|
16
|
+
losses: number;
|
|
17
|
+
/** User's games */
|
|
18
|
+
games: number;
|
|
19
|
+
/** If user is blacklisted */
|
|
20
|
+
blacklist: boolean;
|
|
21
|
+
/** User's accessories such as double point */
|
|
22
|
+
accessories: Accessory[];
|
|
23
|
+
/** User's original channels */
|
|
24
|
+
originalChannels: OriginalChannels;
|
|
25
|
+
/** User's items */
|
|
26
|
+
items: Items;
|
|
27
|
+
/** Creation Date */
|
|
28
|
+
createdAt: Date;
|
|
29
|
+
/** Updated Date */
|
|
30
|
+
updatedAt: Date;
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface APIMessage {
|
|
2
|
+
/** Message's content */
|
|
3
|
+
content: string | object;
|
|
4
|
+
/** Message's creator id */
|
|
5
|
+
userId: string;
|
|
6
|
+
/** Message's type */
|
|
7
|
+
type: "text" | "img" | ".png" | ".gif" | ".jpg";
|
|
8
|
+
/** Creation Date */
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
/** Updated Date */
|
|
11
|
+
updatedAt: Date;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { APIPlayer } from "./APIPlayer";
|
|
2
|
+
export interface APIProduct {
|
|
3
|
+
/** Product's name */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Product's description */
|
|
6
|
+
description: string;
|
|
7
|
+
/** Product's id */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Product's price */
|
|
10
|
+
price: number;
|
|
11
|
+
/** Product's buyers */
|
|
12
|
+
buyers: APIPlayer[];
|
|
13
|
+
/** Product's emoji */
|
|
14
|
+
emoji: string;
|
|
15
|
+
/** Creation Date */
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
/** Updated Date */
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export interface APITicketCategory {
|
|
2
|
+
/** Category's type */
|
|
3
|
+
type: string;
|
|
4
|
+
/** Category's emoji */
|
|
5
|
+
emoji: string;
|
|
6
|
+
/** Category's description */
|
|
7
|
+
description: string;
|
|
8
|
+
/** Category's alias */
|
|
9
|
+
alias: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Blacklisted {
|
|
12
|
+
/** Blacklist's id */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Blacklist added by */
|
|
15
|
+
addedBy: string;
|
|
16
|
+
/** Guild Creation Date */
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
/** Guild Updated Date */
|
|
19
|
+
updatedAt: Date;
|
|
20
|
+
}
|
|
21
|
+
export type GuildBlacklist = Blacklisted[];
|
|
22
|
+
export interface LogMessage {
|
|
23
|
+
/** The message's content */
|
|
24
|
+
content: string | Buffer<any>;
|
|
25
|
+
/** The message's sender */
|
|
26
|
+
userId: string;
|
|
27
|
+
/** The message's type */
|
|
28
|
+
type: string;
|
|
29
|
+
}
|
|
30
|
+
/** Base match modes */
|
|
31
|
+
export type BaseMatchModes = "1x1" | "2x2" | "3x3" | "4x4" | "5x5" | "6x6" | "1v1" | "2v2" | "3v3" | "4v4" | "5v5" | "6v6";
|
|
32
|
+
/** Base match status */
|
|
33
|
+
export type BaseMatchStatus = "on" | "created" | "off" | "shutted";
|
|
34
|
+
/** The logs of the structure */
|
|
35
|
+
export interface Logs {
|
|
36
|
+
/** The messages of the structure */
|
|
37
|
+
messages: LogMessage[];
|
|
38
|
+
}
|
|
39
|
+
/** Original Channel */
|
|
40
|
+
export type OriginalChannel = {
|
|
41
|
+
/** Channel id */
|
|
42
|
+
channelId: string;
|
|
43
|
+
/** Match id */
|
|
44
|
+
matchId: string;
|
|
45
|
+
};
|
|
46
|
+
/** Items */
|
|
47
|
+
export type Items = string[];
|
|
48
|
+
/** Original Channels */
|
|
49
|
+
export type OriginalChannels = OriginalChannel[];
|
|
50
|
+
/** Accessories */
|
|
51
|
+
export type Accessory = {
|
|
52
|
+
/** Accessory type */
|
|
53
|
+
type: "point_protect" | "immunity" | "double_points";
|
|
54
|
+
/** Accessory longevity */
|
|
55
|
+
longevity: string;
|
|
56
|
+
/** Accessory adder */
|
|
57
|
+
addedBy: string;
|
|
58
|
+
/** When accessory added */
|
|
59
|
+
when: Date;
|
|
60
|
+
/** If accessory has expired */
|
|
61
|
+
expired: boolean;
|
|
62
|
+
};
|
|
63
|
+
/** Daily information */
|
|
64
|
+
export type Daily = {
|
|
65
|
+
/** Wins */
|
|
66
|
+
wins: number;
|
|
67
|
+
/** Coins */
|
|
68
|
+
coins: number;
|
|
69
|
+
/** Points */
|
|
70
|
+
points: number;
|
|
71
|
+
/** Credit */
|
|
72
|
+
credit: number;
|
|
73
|
+
/** Losses */
|
|
74
|
+
losses: number;
|
|
75
|
+
/** Mvps */
|
|
76
|
+
mvps: number;
|
|
77
|
+
/** Date of the daily */
|
|
78
|
+
date: Date;
|
|
79
|
+
};
|
|
80
|
+
export interface Banner {
|
|
81
|
+
/** Equipped banner */
|
|
82
|
+
equipped: number;
|
|
83
|
+
/** Bought banners */
|
|
84
|
+
allowed: number[];
|
|
85
|
+
}
|
|
86
|
+
export interface ProfileCard {
|
|
87
|
+
/** Profile's description */
|
|
88
|
+
description: string;
|
|
89
|
+
/** Profile's banner */
|
|
90
|
+
banner: Banner;
|
|
91
|
+
}
|
|
92
|
+
export interface Confirm {
|
|
93
|
+
/** Confirm's type */
|
|
94
|
+
type: string;
|
|
95
|
+
/** Confirm's id */
|
|
96
|
+
ids: string[];
|
|
97
|
+
/** Confirm's counts */
|
|
98
|
+
count: number;
|
|
99
|
+
}
|
|
100
|
+
export type Optional<T> = {
|
|
101
|
+
[K in keyof T]?: T[K];
|
|
102
|
+
};
|
|
103
|
+
export declare enum MATCHTYPES {
|
|
104
|
+
OneVOne = "1v1",
|
|
105
|
+
TwoVTwo = "2v2",
|
|
106
|
+
ThreeVThree = "3v3",
|
|
107
|
+
FourVFour = "4v4",
|
|
108
|
+
FiveVFive = "5v5",
|
|
109
|
+
SixVSix = "6v6"
|
|
110
|
+
}
|
|
111
|
+
export declare enum MATCHSTATUS {
|
|
112
|
+
ON = "on",
|
|
113
|
+
OFF = "off",
|
|
114
|
+
CREATED = "created",
|
|
115
|
+
SHUTTED = "shutted"
|
|
116
|
+
}
|
|
117
|
+
export declare enum BETSTATUS {
|
|
118
|
+
ON = "on",
|
|
119
|
+
OFF = "off",
|
|
120
|
+
CREATED = "created",
|
|
121
|
+
SHUTTED = "shutted",
|
|
122
|
+
WAITING = "waiting"
|
|
123
|
+
}
|
|
124
|
+
export declare enum STATES {
|
|
125
|
+
ON = "on",
|
|
126
|
+
OFF = "off",
|
|
127
|
+
CREATED = "created",
|
|
128
|
+
SHUTTED = "shutted",
|
|
129
|
+
WAITING = "waiting"
|
|
130
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STATES = exports.BETSTATUS = exports.MATCHSTATUS = exports.MATCHTYPES = void 0;
|
|
4
|
+
var MATCHTYPES;
|
|
5
|
+
(function (MATCHTYPES) {
|
|
6
|
+
MATCHTYPES["OneVOne"] = "1v1";
|
|
7
|
+
MATCHTYPES["TwoVTwo"] = "2v2";
|
|
8
|
+
MATCHTYPES["ThreeVThree"] = "3v3";
|
|
9
|
+
MATCHTYPES["FourVFour"] = "4v4";
|
|
10
|
+
MATCHTYPES["FiveVFive"] = "5v5";
|
|
11
|
+
MATCHTYPES["SixVSix"] = "6v6";
|
|
12
|
+
})(MATCHTYPES || (exports.MATCHTYPES = MATCHTYPES = {}));
|
|
13
|
+
var MATCHSTATUS;
|
|
14
|
+
(function (MATCHSTATUS) {
|
|
15
|
+
MATCHSTATUS["ON"] = "on";
|
|
16
|
+
MATCHSTATUS["OFF"] = "off";
|
|
17
|
+
MATCHSTATUS["CREATED"] = "created";
|
|
18
|
+
MATCHSTATUS["SHUTTED"] = "shutted";
|
|
19
|
+
})(MATCHSTATUS || (exports.MATCHSTATUS = MATCHSTATUS = {}));
|
|
20
|
+
var BETSTATUS;
|
|
21
|
+
(function (BETSTATUS) {
|
|
22
|
+
BETSTATUS["ON"] = "on";
|
|
23
|
+
BETSTATUS["OFF"] = "off";
|
|
24
|
+
BETSTATUS["CREATED"] = "created";
|
|
25
|
+
BETSTATUS["SHUTTED"] = "shutted";
|
|
26
|
+
BETSTATUS["WAITING"] = "waiting";
|
|
27
|
+
})(BETSTATUS || (exports.BETSTATUS = BETSTATUS = {}));
|
|
28
|
+
var STATES;
|
|
29
|
+
(function (STATES) {
|
|
30
|
+
STATES["ON"] = "on";
|
|
31
|
+
STATES["OFF"] = "off";
|
|
32
|
+
STATES["CREATED"] = "created";
|
|
33
|
+
STATES["SHUTTED"] = "shutted";
|
|
34
|
+
STATES["WAITING"] = "waiting";
|
|
35
|
+
})(STATES || (exports.STATES = STATES = {}));
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
export * from "./api/APIBaseChannel";
|
|
2
|
-
export * from "./api/APIBetChannel";
|
|
3
|
-
export * from "./api/APIBetMessage";
|
|
4
|
-
export * from "./api/APIGuild";
|
|
5
|
-
export * from "./api/APIGuildBet";
|
|
6
|
-
export * from "./api/APIGuildBetUser";
|
|
7
|
-
export * from "./api/APIGuildChannel";
|
|
8
|
-
export * from "./api/APIGuildEmoji";
|
|
9
|
-
export * from "./api/APIGuildGroupedChannel";
|
|
10
|
-
export * from "./api/APIGuildMatch";
|
|
11
|
-
export * from "./api/APIGuildMediator";
|
|
12
|
-
export * from "./api/APIGuildMessage";
|
|
13
|
-
export * from "./api/APIGuildPermissions";
|
|
14
|
-
export * from "./api/APIGuildRole";
|
|
15
|
-
export * from "./api/APIGuildShop";
|
|
16
|
-
export * from "./api/APIGuildTicket";
|
|
17
|
-
export * from "./api/APIGuildUser";
|
|
18
|
-
export * from "./api/APIMessage";
|
|
19
|
-
export * from "./api/APIPlayer";
|
|
20
|
-
export * from "./api/APIProduct";
|
|
21
|
-
|
|
22
|
-
export * from "./api/index";
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
export * from "./api/APIBaseChannel";
|
|
2
|
+
export * from "./api/APIBetChannel";
|
|
3
|
+
export * from "./api/APIBetMessage";
|
|
4
|
+
export * from "./api/APIGuild";
|
|
5
|
+
export * from "./api/APIGuildBet";
|
|
6
|
+
export * from "./api/APIGuildBetUser";
|
|
7
|
+
export * from "./api/APIGuildChannel";
|
|
8
|
+
export * from "./api/APIGuildEmoji";
|
|
9
|
+
export * from "./api/APIGuildGroupedChannel";
|
|
10
|
+
export * from "./api/APIGuildMatch";
|
|
11
|
+
export * from "./api/APIGuildMediator";
|
|
12
|
+
export * from "./api/APIGuildMessage";
|
|
13
|
+
export * from "./api/APIGuildPermissions";
|
|
14
|
+
export * from "./api/APIGuildRole";
|
|
15
|
+
export * from "./api/APIGuildShop";
|
|
16
|
+
export * from "./api/APIGuildTicket";
|
|
17
|
+
export * from "./api/APIGuildUser";
|
|
18
|
+
export * from "./api/APIMessage";
|
|
19
|
+
export * from "./api/APIPlayer";
|
|
20
|
+
export * from "./api/APIProduct";
|
|
21
|
+
export * from "./api/index";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api/APIBaseChannel"), exports);
|
|
18
|
+
__exportStar(require("./api/APIBetChannel"), exports);
|
|
19
|
+
__exportStar(require("./api/APIBetMessage"), exports);
|
|
20
|
+
__exportStar(require("./api/APIGuild"), exports);
|
|
21
|
+
__exportStar(require("./api/APIGuildBet"), exports);
|
|
22
|
+
__exportStar(require("./api/APIGuildBetUser"), exports);
|
|
23
|
+
__exportStar(require("./api/APIGuildChannel"), exports);
|
|
24
|
+
__exportStar(require("./api/APIGuildEmoji"), exports);
|
|
25
|
+
__exportStar(require("./api/APIGuildGroupedChannel"), exports);
|
|
26
|
+
__exportStar(require("./api/APIGuildMatch"), exports);
|
|
27
|
+
__exportStar(require("./api/APIGuildMediator"), exports);
|
|
28
|
+
__exportStar(require("./api/APIGuildMessage"), exports);
|
|
29
|
+
__exportStar(require("./api/APIGuildPermissions"), exports);
|
|
30
|
+
__exportStar(require("./api/APIGuildRole"), exports);
|
|
31
|
+
__exportStar(require("./api/APIGuildShop"), exports);
|
|
32
|
+
__exportStar(require("./api/APIGuildTicket"), exports);
|
|
33
|
+
__exportStar(require("./api/APIGuildUser"), exports);
|
|
34
|
+
__exportStar(require("./api/APIMessage"), exports);
|
|
35
|
+
__exportStar(require("./api/APIPlayer"), exports);
|
|
36
|
+
__exportStar(require("./api/APIProduct"), exports);
|
|
37
|
+
__exportStar(require("./api/index"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class used to assert types in the sdk
|
|
3
|
+
*/
|
|
4
|
+
export declare class Assertion {
|
|
5
|
+
constructor();
|
|
6
|
+
/**
|
|
7
|
+
* Tests if given key is a string
|
|
8
|
+
* @param key Key to test
|
|
9
|
+
*/
|
|
10
|
+
static assertString(key: unknown): key is string;
|
|
11
|
+
/**
|
|
12
|
+
* Tests if given key is a number
|
|
13
|
+
* @param key Key to test
|
|
14
|
+
*/
|
|
15
|
+
static assertNumber(key: unknown): key is number;
|
|
16
|
+
/**
|
|
17
|
+
* Tests if given key is a boolean
|
|
18
|
+
* @param key Key to test
|
|
19
|
+
*/
|
|
20
|
+
static assertBoolean(key: unknown): key is boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Tests if given key is an array
|
|
23
|
+
* @param key Key to test
|
|
24
|
+
*/
|
|
25
|
+
static assertArray(key: unknown): key is object;
|
|
26
|
+
/**
|
|
27
|
+
* Tests if given key is an object
|
|
28
|
+
* @param key Key to test
|
|
29
|
+
*/
|
|
30
|
+
static assertObject(key: unknown): key is object;
|
|
31
|
+
toString(): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Assertion = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Class used to assert types in the sdk
|
|
6
|
+
*/
|
|
7
|
+
class Assertion {
|
|
8
|
+
constructor() { }
|
|
9
|
+
/**
|
|
10
|
+
* Tests if given key is a string
|
|
11
|
+
* @param key Key to test
|
|
12
|
+
*/
|
|
13
|
+
static assertString(key) {
|
|
14
|
+
if (typeof key !== "string")
|
|
15
|
+
throw new Error(`${key} must be a string`);
|
|
16
|
+
if (!key || key === "")
|
|
17
|
+
throw new Error(`${key} must be a string`);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Tests if given key is a number
|
|
22
|
+
* @param key Key to test
|
|
23
|
+
*/
|
|
24
|
+
static assertNumber(key) {
|
|
25
|
+
if (typeof key !== "number")
|
|
26
|
+
throw new Error(`${key} must be a number`);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tests if given key is a boolean
|
|
31
|
+
* @param key Key to test
|
|
32
|
+
*/
|
|
33
|
+
static assertBoolean(key) {
|
|
34
|
+
if (typeof key !== "boolean")
|
|
35
|
+
throw new Error(`${key} must be a boolean`);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Tests if given key is an array
|
|
40
|
+
* @param key Key to test
|
|
41
|
+
*/
|
|
42
|
+
static assertArray(key) {
|
|
43
|
+
if (!Array.isArray(key))
|
|
44
|
+
throw new Error(`${key} must be an array`);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Tests if given key is an object
|
|
49
|
+
* @param key Key to test
|
|
50
|
+
*/
|
|
51
|
+
static assertObject(key) {
|
|
52
|
+
if (typeof key !== "object")
|
|
53
|
+
throw new Error(`${key} must be an object`);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
toString() {
|
|
57
|
+
return 'string, number, boolean, array, object';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Assertion = Assertion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duque.edits/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"SDK",
|
|
13
13
|
"DuqueEdits"
|
|
14
14
|
],
|
|
15
|
+
"files": [
|
|
16
|
+
"./dist",
|
|
17
|
+
"./package.json"
|
|
18
|
+
],
|
|
15
19
|
"scripts": {
|
|
16
20
|
"test": "ts-node tests/index.ts"
|
|
17
21
|
},
|
package/.gitattributes
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { REST } from "../../rest/REST";
|
|
2
|
-
import { Routes } from "../../rest/Routes";
|
|
3
|
-
import { GuildBet } from "../../structures/bet/GuildBet";
|
|
4
|
-
import { Collection } from "../../structures/Collection";
|
|
5
|
-
import { Guild } from "../../structures/guild/Guild";
|
|
6
|
-
import { Optional } from "../../types/api";
|
|
7
|
-
import { APIGuildBet } from "../../types/api/APIGuildBet";
|
|
8
|
-
import { Assertion } from "../../utils/Assertion";
|
|
9
|
-
|
|
10
|
-
export class GuildBetManager {
|
|
11
|
-
/** A cache of users */
|
|
12
|
-
cache: Collection<string, GuildBet>;
|
|
13
|
-
|
|
14
|
-
/** The rest client */
|
|
15
|
-
rest: REST;
|
|
16
|
-
|
|
17
|
-
/** GuildBet bet guild */
|
|
18
|
-
guild: Guild;
|
|
19
|
-
/**
|
|
20
|
-
* Manage users with the given client
|
|
21
|
-
* @param users An array of users
|
|
22
|
-
* @param rest The rest client
|
|
23
|
-
*/
|
|
24
|
-
constructor(guild: Guild, rest: REST) {
|
|
25
|
-
this.guild = guild;
|
|
26
|
-
this.rest = rest;
|
|
27
|
-
|
|
28
|
-
this.cache = new Collection<string, GuildBet>("bets");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async create(payload: Optional<APIGuildBet>): Promise<GuildBet> {
|
|
32
|
-
Assertion.assertObject(payload);
|
|
33
|
-
|
|
34
|
-
const route = Routes.guilds.bets.create(this.guild.id);
|
|
35
|
-
const response = await this.rest.request<APIGuildBet, typeof payload>({
|
|
36
|
-
method: "POST",
|
|
37
|
-
url: route,
|
|
38
|
-
});
|
|
39
|
-
const bet = this.set(response);
|
|
40
|
-
return bet;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Fetch a bet
|
|
45
|
-
* @param id Id of the bet to fetch
|
|
46
|
-
* @returns APIBetUser
|
|
47
|
-
*/
|
|
48
|
-
async fetch(id: string) {
|
|
49
|
-
const route = Routes.guilds.bets.get(this.guild.id, id);
|
|
50
|
-
const response = await this.rest.request<APIGuildBet, {}>({
|
|
51
|
-
method: "get",
|
|
52
|
-
url: route,
|
|
53
|
-
});
|
|
54
|
-
const bet = new GuildBet(response, this.guild, this, this.rest);
|
|
55
|
-
this.cache.set(bet._id, bet);
|
|
56
|
-
this.rest.bets.set(bet._id, bet);
|
|
57
|
-
|
|
58
|
-
return bet;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async fetchAll() {
|
|
62
|
-
const route = Routes.guilds.bets.getAll(this.guild.id);
|
|
63
|
-
const response = await this.rest.request<APIGuildBet[], {}>({
|
|
64
|
-
method: "get",
|
|
65
|
-
url: route,
|
|
66
|
-
});
|
|
67
|
-
if (Array.isArray(response) && response.length === 0) {
|
|
68
|
-
this.cache.clear();
|
|
69
|
-
return this.cache;
|
|
70
|
-
}
|
|
71
|
-
for (let betData of response) {
|
|
72
|
-
const bet = new GuildBet(betData, this.guild, this, this.rest);
|
|
73
|
-
this.cache.set(bet._id, bet);
|
|
74
|
-
}
|
|
75
|
-
return this.cache;
|
|
76
|
-
}
|
|
77
|
-
set(data: APIGuildBet): GuildBet {
|
|
78
|
-
if (!data._id) return;
|
|
79
|
-
const bet = new GuildBet(data, this.guild, this, this.rest);
|
|
80
|
-
this.cache.set(bet._id, bet);
|
|
81
|
-
this.rest.bets.set(bet._id, bet);
|
|
82
|
-
|
|
83
|
-
return bet;
|
|
84
|
-
}
|
|
85
|
-
setAll(data: APIGuildBet[]) {
|
|
86
|
-
if (!data) return this.cache;
|
|
87
|
-
for (let bet of data) this.set(bet);
|
|
88
|
-
return this.cache;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
async delete(id: string) {
|
|
92
|
-
Assertion.assertString(id);
|
|
93
|
-
|
|
94
|
-
const route = Routes.guilds.bets.delete(id, this.guild.id);
|
|
95
|
-
const bet = this.cache.get(id);
|
|
96
|
-
this.rest.emit("betDelete", bet);
|
|
97
|
-
|
|
98
|
-
await this.rest.request<boolean, {}>({
|
|
99
|
-
method: "DELETE",
|
|
100
|
-
url: route,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
this.cache.delete(id);
|
|
104
|
-
return this.cache;
|
|
105
|
-
}
|
|
106
|
-
async deleteAll() {
|
|
107
|
-
const route = Routes.guilds.bets.deleteAll(this.guild.id);
|
|
108
|
-
this.rest.emit("betsDelete", this.cache);
|
|
109
|
-
|
|
110
|
-
const value = await this.rest.request<boolean, {}>({
|
|
111
|
-
method: "DELETE",
|
|
112
|
-
url: route,
|
|
113
|
-
});
|
|
114
|
-
this.cache.clear();
|
|
115
|
-
return value;
|
|
116
|
-
}
|
|
117
|
-
};
|