@duque.edits/sdk 0.1.4 → 0.1.6
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/index.js +4 -27
- package/dist/managers/base.js +26 -0
- package/dist/managers/buffer/BufferManager.js +8 -2
- package/dist/managers/guild/GuildManager.js +42 -25
- package/dist/managers/index.js +23 -0
- package/dist/managers/match/GuildMatchManager.js +42 -29
- package/dist/managers/message/MessagesManager.js +48 -0
- package/dist/managers/permission/GuildPermissionManager.js +29 -52
- package/dist/managers/ticket/TicketManager.js +77 -0
- package/dist/managers/user/GuildUserManager.js +73 -85
- package/dist/managers/vipmember/VipMemberManager.js +124 -0
- package/dist/rest/REST.js +40 -21
- package/dist/rest/Routes.js +31 -17
- package/dist/rest/index.js +19 -0
- package/dist/structures/Collection.js +1 -1
- package/dist/structures/guild/Guild.js +72 -90
- package/dist/structures/index.js +22 -0
- package/dist/structures/match/GuildMatch.js +64 -111
- package/dist/structures/ticket/Ticket.js +119 -0
- package/dist/structures/user/GuildUser.js +48 -40
- package/dist/structures/vipmember/VipMember.js +137 -0
- package/dist/types/api/APIGiveaway.js +2 -0
- package/dist/types/api/APILogMessage.js +2 -0
- package/dist/types/api/APIVipMember.js +2 -0
- package/dist/types/api/index.js +36 -0
- package/dist/types/index.js +1 -20
- package/dist/utils/getRandomNumber.js +6 -0
- package/package.json +11 -18
- package/types/index.d.ts +4 -0
- package/types/managers/base.d.ts +17 -0
- package/types/managers/buffer/BufferManager.d.ts +19 -0
- package/{dist → types}/managers/guild/GuildManager.d.ts +12 -4
- package/types/managers/index.d.ts +7 -0
- package/{dist → types}/managers/match/GuildMatchManager.d.ts +10 -12
- package/types/managers/message/MessagesManager.d.ts +17 -0
- package/types/managers/permission/GuildPermissionManager.d.ts +8 -0
- package/types/managers/ticket/TicketManager.d.ts +22 -0
- package/types/managers/user/GuildUserManager.d.ts +19 -0
- package/types/managers/vipmember/VipMemberManager.d.ts +33 -0
- package/types/rest/APIEndpoints.d.ts +11 -0
- package/{dist → types}/rest/REST.d.ts +9 -16
- package/{dist → types}/rest/Routes.d.ts +18 -2
- package/types/rest/index.d.ts +3 -0
- package/{dist → types}/structures/guild/Guild.d.ts +17 -29
- package/types/structures/index.d.ts +6 -0
- package/{dist → types}/structures/match/GuildMatch.d.ts +12 -22
- package/types/structures/ticket/Ticket.d.ts +30 -0
- package/{dist → types}/structures/user/GuildUser.d.ts +5 -3
- package/types/structures/vipmember/VipMember.d.ts +54 -0
- package/types/types/RestTypes.d.ts +34 -0
- package/types/types/api/APIGiveaway.d.ts +27 -0
- package/{dist → types}/types/api/APIGuild.d.ts +9 -2
- package/{dist → types}/types/api/APIGuildMatch.d.ts +9 -7
- package/types/types/api/APIGuildTicket.d.ts +16 -0
- package/{dist → types}/types/api/APIGuildUser.d.ts +3 -1
- package/types/types/api/APILogMessage.d.ts +7 -0
- package/types/types/api/APIMessage.d.ts +11 -0
- package/{dist → types}/types/api/APIPlayer.d.ts +1 -1
- package/types/types/api/APIVipMember.d.ts +20 -0
- package/{dist → types}/types/api/index.d.ts +23 -1
- package/types/types/index.d.ts +2 -0
- package/types/utils/getRandomNumber.d.ts +1 -0
- package/dist/index.d.ts +0 -27
- package/dist/managers/bet/GuildBetManager.d.ts +0 -35
- package/dist/managers/bet/GuildBetManager.js +0 -126
- package/dist/managers/betuser/GuildBetUserManager.d.ts +0 -36
- package/dist/managers/betuser/GuildBetUserManager.js +0 -151
- package/dist/managers/buffer/BufferManager.d.ts +0 -14
- package/dist/managers/channel/ChannelManager.d.ts +0 -39
- package/dist/managers/channel/ChannelManager.js +0 -148
- package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +0 -34
- package/dist/managers/groupedchannel/GroupedChannelManager.js +0 -92
- package/dist/managers/mediator/GuildMediatorManager.d.ts +0 -32
- package/dist/managers/mediator/GuildMediatorManager.js +0 -98
- package/dist/managers/messages/MessagesManager.d.ts +0 -32
- package/dist/managers/messages/MessagesManager.js +0 -89
- package/dist/managers/permission/GuildPermissionManager.d.ts +0 -26
- package/dist/managers/product/GuildProductManager.d.ts +0 -32
- package/dist/managers/product/GuildProductManager.js +0 -103
- package/dist/managers/ticket/GuildTicketManager.d.ts +0 -32
- package/dist/managers/ticket/GuildTicketManager.js +0 -100
- package/dist/managers/user/GuildUserManager.d.ts +0 -33
- package/dist/rest/APIEndpoints.d.ts +0 -11
- package/dist/structures/bet/GuildBet.d.ts +0 -87
- package/dist/structures/bet/GuildBet.js +0 -284
- package/dist/structures/betuser/GuildBetUser.d.ts +0 -85
- package/dist/structures/betuser/GuildBetUser.js +0 -211
- package/dist/structures/channel/Channel.d.ts +0 -31
- package/dist/structures/channel/Channel.js +0 -57
- package/dist/structures/groupedchannel/GroupedChannel.d.ts +0 -34
- package/dist/structures/groupedchannel/GroupedChannel.js +0 -121
- package/dist/structures/mediator/GuildMediator.d.ts +0 -41
- package/dist/structures/mediator/GuildMediator.js +0 -131
- package/dist/structures/product/GuildProduct.d.ts +0 -52
- package/dist/structures/product/GuildProduct.js +0 -175
- package/dist/structures/shop/GuildShop.d.ts +0 -34
- package/dist/structures/shop/GuildShop.js +0 -80
- package/dist/structures/ticket/GuildTicket.d.ts +0 -52
- package/dist/structures/ticket/GuildTicket.js +0 -172
- package/dist/types/api/APIGuildTicket.d.ts +0 -26
- package/dist/types/api/APIMessage.d.ts +0 -12
- package/dist/types/index.d.ts +0 -21
- /package/dist/types/{api/APIGuildMessage.js → RestTypes.js} +0 -0
- /package/{dist → types}/structures/Collection.d.ts +0 -0
- /package/{dist → types}/types/api/APIBaseChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIBetChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIBetMessage.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildBet.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildBetUser.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildEmoji.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildGroupedChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildMediator.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildMessage.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildPermissions.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildRole.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildShop.d.ts +0 -0
- /package/{dist → types}/types/api/APIProduct.d.ts +0 -0
- /package/{dist → types}/utils/Assertion.d.ts +0 -0
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { REST } from "../../rest/REST";
|
|
2
|
-
import { GuildTicket } from "../../structures/ticket/GuildTicket";
|
|
3
|
-
import { Collection } from "../../structures/Collection";
|
|
4
|
-
import { Guild } from "../../structures/guild/Guild";
|
|
5
|
-
import { Optional } from "../../types/api";
|
|
6
|
-
import { APIGuildTicket } from "../../types/api/APIGuildTicket";
|
|
7
|
-
export declare class GuildTicketManager {
|
|
8
|
-
/** A cache of users */
|
|
9
|
-
cache: Collection<string, GuildTicket>;
|
|
10
|
-
/** The rest client */
|
|
11
|
-
rest: REST;
|
|
12
|
-
/** GuildTicket ticket guild */
|
|
13
|
-
guild: Guild;
|
|
14
|
-
/**
|
|
15
|
-
* Manage users with the given client
|
|
16
|
-
* @param users An array of users
|
|
17
|
-
* @param rest The rest client
|
|
18
|
-
*/
|
|
19
|
-
constructor(guild: Guild, rest: REST);
|
|
20
|
-
create(payload: Optional<APIGuildTicket>): Promise<GuildTicket>;
|
|
21
|
-
/**
|
|
22
|
-
* Fetch a ticket
|
|
23
|
-
* @param id Id of the ticket to fetch
|
|
24
|
-
* @returns APIticketUser
|
|
25
|
-
*/
|
|
26
|
-
fetch(id: string): Promise<GuildTicket>;
|
|
27
|
-
fetchAll(): Promise<Collection<string, GuildTicket>>;
|
|
28
|
-
set(data: APIGuildTicket): GuildTicket;
|
|
29
|
-
setAll(data: APIGuildTicket[]): Collection<string, GuildTicket>;
|
|
30
|
-
delete(id: string): Promise<Collection<string, GuildTicket>>;
|
|
31
|
-
deleteAll(): Promise<boolean>;
|
|
32
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuildTicketManager = void 0;
|
|
4
|
-
const Routes_1 = require("../../rest/Routes");
|
|
5
|
-
const GuildTicket_1 = require("../../structures/ticket/GuildTicket");
|
|
6
|
-
const Collection_1 = require("../../structures/Collection");
|
|
7
|
-
const Assertion_1 = require("../../utils/Assertion");
|
|
8
|
-
class GuildTicketManager {
|
|
9
|
-
/** A cache of users */
|
|
10
|
-
cache;
|
|
11
|
-
/** The rest client */
|
|
12
|
-
rest;
|
|
13
|
-
/** GuildTicket ticket guild */
|
|
14
|
-
guild;
|
|
15
|
-
/**
|
|
16
|
-
* Manage users with the given client
|
|
17
|
-
* @param users An array of users
|
|
18
|
-
* @param rest The rest client
|
|
19
|
-
*/
|
|
20
|
-
constructor(guild, rest) {
|
|
21
|
-
this.guild = guild;
|
|
22
|
-
this.rest = rest;
|
|
23
|
-
this.cache = new Collection_1.Collection("tickets");
|
|
24
|
-
}
|
|
25
|
-
async create(payload) {
|
|
26
|
-
Assertion_1.Assertion.assertObject(payload);
|
|
27
|
-
const route = Routes_1.Routes.guilds.tickets.create(this.guild.id);
|
|
28
|
-
const response = await this.rest.request({
|
|
29
|
-
method: "POST",
|
|
30
|
-
url: route,
|
|
31
|
-
payload,
|
|
32
|
-
});
|
|
33
|
-
const ticket = this.set(response);
|
|
34
|
-
return ticket;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Fetch a ticket
|
|
38
|
-
* @param id Id of the ticket to fetch
|
|
39
|
-
* @returns APIticketUser
|
|
40
|
-
*/
|
|
41
|
-
async fetch(id) {
|
|
42
|
-
const route = Routes_1.Routes.guilds.tickets.get(this.guild.id, id);
|
|
43
|
-
const response = await this.rest.request({
|
|
44
|
-
method: "get",
|
|
45
|
-
url: route,
|
|
46
|
-
});
|
|
47
|
-
const ticket = new GuildTicket_1.GuildTicket(response, this.guild, this, this.rest);
|
|
48
|
-
this.cache.set(ticket.id, ticket);
|
|
49
|
-
return ticket;
|
|
50
|
-
}
|
|
51
|
-
async fetchAll() {
|
|
52
|
-
const route = Routes_1.Routes.guilds.tickets.getAll(this.guild.id);
|
|
53
|
-
const response = await this.rest.request({
|
|
54
|
-
method: "get",
|
|
55
|
-
url: route,
|
|
56
|
-
});
|
|
57
|
-
for (let ticketData of response) {
|
|
58
|
-
const ticket = new GuildTicket_1.GuildTicket(ticketData, this.guild, this, this.rest);
|
|
59
|
-
this.cache.set(ticket.id, ticket);
|
|
60
|
-
}
|
|
61
|
-
return this.cache;
|
|
62
|
-
}
|
|
63
|
-
set(data) {
|
|
64
|
-
if (!data?.id)
|
|
65
|
-
return;
|
|
66
|
-
const ticket = new GuildTicket_1.GuildTicket(data, this.guild, this, this.rest);
|
|
67
|
-
this.cache.set(data?.id?.toString(), ticket);
|
|
68
|
-
return ticket;
|
|
69
|
-
}
|
|
70
|
-
setAll(data) {
|
|
71
|
-
if (!data)
|
|
72
|
-
return this.cache;
|
|
73
|
-
for (let ticket of data)
|
|
74
|
-
this.set(ticket);
|
|
75
|
-
return this.cache;
|
|
76
|
-
}
|
|
77
|
-
async delete(id) {
|
|
78
|
-
Assertion_1.Assertion.assertString(id);
|
|
79
|
-
const route = Routes_1.Routes.guilds.tickets.delete(id, this.guild.id);
|
|
80
|
-
const ticket = this.cache.get(id);
|
|
81
|
-
this.rest.emit("ticketDelete", ticket);
|
|
82
|
-
await this.rest.request({
|
|
83
|
-
method: "DELETE",
|
|
84
|
-
url: route,
|
|
85
|
-
});
|
|
86
|
-
this.cache.delete(id);
|
|
87
|
-
return this.cache;
|
|
88
|
-
}
|
|
89
|
-
async deleteAll() {
|
|
90
|
-
const route = Routes_1.Routes.guilds.tickets.deleteAll(this.guild.id);
|
|
91
|
-
this.rest.emit("ticketsDelete", this.cache);
|
|
92
|
-
const value = await this.rest.request({
|
|
93
|
-
method: "DELETE",
|
|
94
|
-
url: route,
|
|
95
|
-
});
|
|
96
|
-
this.cache.clear();
|
|
97
|
-
return value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.GuildTicketManager = GuildTicketManager;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { REST } from "../../rest/REST";
|
|
2
|
-
import { GuildUser } from "../../structures/user/GuildUser";
|
|
3
|
-
import { Collection } from "../../structures/Collection";
|
|
4
|
-
import { Guild } from "../../structures/guild/Guild";
|
|
5
|
-
import { APIGuildUser } from "../../types/api/APIGuildUser";
|
|
6
|
-
import { Optional } from "../../types";
|
|
7
|
-
export declare class GuildUserManager {
|
|
8
|
-
/** A cache of users */
|
|
9
|
-
cache: Collection<string, GuildUser>;
|
|
10
|
-
/** The rest client */
|
|
11
|
-
rest: REST;
|
|
12
|
-
/** Bet user guild */
|
|
13
|
-
guild: Guild;
|
|
14
|
-
/**
|
|
15
|
-
* Manage users with the given client
|
|
16
|
-
* @param users An array of users
|
|
17
|
-
* @param rest The rest client
|
|
18
|
-
*/
|
|
19
|
-
constructor(guild: Guild, rest: REST);
|
|
20
|
-
/**
|
|
21
|
-
* Fetch a user
|
|
22
|
-
* @param id Id of the user to fetch
|
|
23
|
-
* @returns GuildUser
|
|
24
|
-
*/
|
|
25
|
-
fetch(id: string, name: string): Promise<GuildUser>;
|
|
26
|
-
fetchAll(): Promise<Collection<string, GuildUser>>;
|
|
27
|
-
updateUser(id: string, name: string, data: Optional<APIGuildUser>): Promise<GuildUser>;
|
|
28
|
-
set(data: APIGuildUser): GuildUser;
|
|
29
|
-
setAll(data: APIGuildUser[]): Collection<string, GuildUser>;
|
|
30
|
-
resetAll(): Promise<Collection<string, GuildUser>>;
|
|
31
|
-
delete(id: string): Promise<Collection<string, GuildUser>>;
|
|
32
|
-
deleteAll(): Promise<boolean>;
|
|
33
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { REST } from "../../rest/REST";
|
|
2
|
-
import { Guild } from "../guild/Guild";
|
|
3
|
-
import { APIGuildBet } from "../../types/api/APIGuildBet";
|
|
4
|
-
import { APIPlayer } from "../../types/api/APIPlayer";
|
|
5
|
-
import { APIBetChannel } from "../../types/api/APIBetChannel";
|
|
6
|
-
import { BaseMatchModes, BaseMatchStatus, Confirm, Logs, Optional } from "../../types/api";
|
|
7
|
-
import { ChannelManager } from "../../managers/channel/ChannelManager";
|
|
8
|
-
import { GuildBetManager } from "../../managers/bet/GuildBetManager";
|
|
9
|
-
import { MessagesManager } from "../../managers/messages/MessagesManager";
|
|
10
|
-
type ExtendedMatchStatus = BaseMatchStatus | "waiting";
|
|
11
|
-
export declare class GuildBet {
|
|
12
|
-
/** The bet's type */
|
|
13
|
-
type: Omit<BaseMatchModes, "5x5" | "6x6" | "5v5" | "6v6">;
|
|
14
|
-
/** The bet's mode */
|
|
15
|
-
mode: "misto" | "emu" | "mob" | "MISTO" | "EMU" | "MOB";
|
|
16
|
-
/** The bet's status */
|
|
17
|
-
status: "off" | "created" | "on" | "shutted" | "waiting";
|
|
18
|
-
/** The bet's maximum size */
|
|
19
|
-
maximumSize: number;
|
|
20
|
-
/** The bet's price */
|
|
21
|
-
price: number;
|
|
22
|
-
/** Who has payed the bet */
|
|
23
|
-
payedBy: APIPlayer[];
|
|
24
|
-
/** The bet's players */
|
|
25
|
-
players: APIPlayer[];
|
|
26
|
-
/** An array of team a */
|
|
27
|
-
teamA: APIPlayer[];
|
|
28
|
-
/** An array of team b */
|
|
29
|
-
teamB: APIPlayer[];
|
|
30
|
-
/** The bet's channel */
|
|
31
|
-
channels: ChannelManager<GuildBet>;
|
|
32
|
-
/** THe bet's messages */
|
|
33
|
-
messages: MessagesManager;
|
|
34
|
-
/** The id of the winner */
|
|
35
|
-
winner: string;
|
|
36
|
-
/** The id of the loser */
|
|
37
|
-
loser: string;
|
|
38
|
-
/** The bet's creator id */
|
|
39
|
-
creatorId: string;
|
|
40
|
-
/** The bet's mediator */
|
|
41
|
-
mediatorId: string;
|
|
42
|
-
/** The bet's confirmers */
|
|
43
|
-
confirmed: Confirm[];
|
|
44
|
-
/** The bet's embed id */
|
|
45
|
-
embedMessageId: string;
|
|
46
|
-
/** The bet's logs */
|
|
47
|
-
logs: Logs;
|
|
48
|
-
/** Creation Date */
|
|
49
|
-
createdAt: Date;
|
|
50
|
-
/** Updated Date */
|
|
51
|
-
updatedAt: Date;
|
|
52
|
-
/** GuildBet's id */
|
|
53
|
-
_id: string;
|
|
54
|
-
/** The given guild */
|
|
55
|
-
readonly guild: Guild;
|
|
56
|
-
/** The rest client */
|
|
57
|
-
readonly rest: REST;
|
|
58
|
-
readonly key: string;
|
|
59
|
-
readonly manager: GuildBetManager;
|
|
60
|
-
/**
|
|
61
|
-
* GuildBet bet
|
|
62
|
-
* @param data The bet's data
|
|
63
|
-
* @param guild The guild
|
|
64
|
-
* @param rest The rest client
|
|
65
|
-
*/
|
|
66
|
-
constructor(data: APIGuildBet, guild: Guild, manager: GuildBetManager, rest: REST);
|
|
67
|
-
toString(): string;
|
|
68
|
-
/**
|
|
69
|
-
* Fetches the bet
|
|
70
|
-
* @returns New Instance of the bet
|
|
71
|
-
*/
|
|
72
|
-
fetch(): Promise<GuildBet>;
|
|
73
|
-
addConfirmed(type: string, id: string): Promise<Confirm>;
|
|
74
|
-
setConfirmed(set: Confirm[]): Promise<Confirm[]>;
|
|
75
|
-
setStatus(status: ExtendedMatchStatus): Promise<this>;
|
|
76
|
-
setWinner(userId: string): Promise<string>;
|
|
77
|
-
setLoser(userId: string): Promise<string>;
|
|
78
|
-
delete(): Promise<boolean>;
|
|
79
|
-
addChannel(id: string, type: string): Promise<import("../..").Channel<GuildBet>>;
|
|
80
|
-
addMessage(id: string, type: string, content?: string): Promise<boolean>;
|
|
81
|
-
setChannels(channels: APIBetChannel[]): Promise<ChannelManager<GuildBet>>;
|
|
82
|
-
addPlayer(player: Optional<APIPlayer>): Promise<APIPlayer[]>;
|
|
83
|
-
removePlayer(player: Optional<APIPlayer>): Promise<APIPlayer[]>;
|
|
84
|
-
update(data: Optional<APIGuildBet>): Promise<this>;
|
|
85
|
-
toJSON(): Record<string, unknown>;
|
|
86
|
-
}
|
|
87
|
-
export {};
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuildBet = void 0;
|
|
4
|
-
const Routes_1 = require("../../rest/Routes");
|
|
5
|
-
const Assertion_1 = require("../../utils/Assertion");
|
|
6
|
-
const ChannelManager_1 = require("../../managers/channel/ChannelManager");
|
|
7
|
-
const MessagesManager_1 = require("../../managers/messages/MessagesManager");
|
|
8
|
-
class GuildBet {
|
|
9
|
-
/** The bet's type */
|
|
10
|
-
type;
|
|
11
|
-
/** The bet's mode */
|
|
12
|
-
mode;
|
|
13
|
-
/** The bet's status */
|
|
14
|
-
status;
|
|
15
|
-
/** The bet's maximum size */
|
|
16
|
-
maximumSize;
|
|
17
|
-
/** The bet's price */
|
|
18
|
-
price;
|
|
19
|
-
/** Who has payed the bet */
|
|
20
|
-
payedBy;
|
|
21
|
-
/** The bet's players */
|
|
22
|
-
players;
|
|
23
|
-
/** An array of team a */
|
|
24
|
-
teamA;
|
|
25
|
-
/** An array of team b */
|
|
26
|
-
teamB;
|
|
27
|
-
/** The bet's channel */
|
|
28
|
-
channels;
|
|
29
|
-
/** THe bet's messages */
|
|
30
|
-
messages;
|
|
31
|
-
/** The id of the winner */
|
|
32
|
-
winner;
|
|
33
|
-
/** The id of the loser */
|
|
34
|
-
loser;
|
|
35
|
-
/** The bet's creator id */
|
|
36
|
-
creatorId;
|
|
37
|
-
/** The bet's mediator */
|
|
38
|
-
mediatorId;
|
|
39
|
-
/** The bet's confirmers */
|
|
40
|
-
confirmed;
|
|
41
|
-
/** The bet's embed id */
|
|
42
|
-
embedMessageId;
|
|
43
|
-
/** The bet's logs */
|
|
44
|
-
logs;
|
|
45
|
-
/** Creation Date */
|
|
46
|
-
createdAt;
|
|
47
|
-
/** Updated Date */
|
|
48
|
-
updatedAt;
|
|
49
|
-
/** GuildBet's id */
|
|
50
|
-
_id;
|
|
51
|
-
/** The given guild */
|
|
52
|
-
guild;
|
|
53
|
-
/** The rest client */
|
|
54
|
-
rest;
|
|
55
|
-
key;
|
|
56
|
-
manager;
|
|
57
|
-
/**
|
|
58
|
-
* GuildBet bet
|
|
59
|
-
* @param data The bet's data
|
|
60
|
-
* @param guild The guild
|
|
61
|
-
* @param rest The rest client
|
|
62
|
-
*/
|
|
63
|
-
constructor(data, guild, manager, rest) {
|
|
64
|
-
this.type = data?.type;
|
|
65
|
-
this.mode = data?.mode;
|
|
66
|
-
this.status = data?.status;
|
|
67
|
-
this.maximumSize = data?.maximumSize;
|
|
68
|
-
this.price = data?.price;
|
|
69
|
-
this.payedBy = data?.payedBy;
|
|
70
|
-
this.players = data?.players;
|
|
71
|
-
this.teamA = data?.teamA;
|
|
72
|
-
this.teamB = data?.teamB;
|
|
73
|
-
this.winner = data?.winner;
|
|
74
|
-
this.loser = data?.loser;
|
|
75
|
-
this.creatorId = data?.creatorId;
|
|
76
|
-
this.mediatorId = data?.mediatorId;
|
|
77
|
-
this.confirmed = data?.confirmed;
|
|
78
|
-
this.embedMessageId = data?.embedMessageId;
|
|
79
|
-
this.winner = data?.winner;
|
|
80
|
-
this.loser = data?.loser;
|
|
81
|
-
this._id = data?._id;
|
|
82
|
-
this.logs = data?.logs;
|
|
83
|
-
this.guild = guild;
|
|
84
|
-
this.rest = rest;
|
|
85
|
-
this.manager = manager;
|
|
86
|
-
this.key = "bets";
|
|
87
|
-
this.channels = new ChannelManager_1.ChannelManager(guild, this, rest);
|
|
88
|
-
this.messages = new MessagesManager_1.MessagesManager(this?.guild, `bets/${data?._id}`, rest);
|
|
89
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
90
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
91
|
-
this.channels.setAll(data?.channels);
|
|
92
|
-
this.messages.setAll(data?.messages);
|
|
93
|
-
}
|
|
94
|
-
toString() {
|
|
95
|
-
return this._id || "1";
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Fetches the bet
|
|
99
|
-
* @returns New Instance of the bet
|
|
100
|
-
*/
|
|
101
|
-
async fetch() {
|
|
102
|
-
const route = Routes_1.Routes.guilds.bets.get(this.guild.id, this._id);
|
|
103
|
-
const response = await this.rest.request({
|
|
104
|
-
method: "get",
|
|
105
|
-
url: route,
|
|
106
|
-
});
|
|
107
|
-
const bt = new GuildBet(response, this.guild, this.manager, this.rest);
|
|
108
|
-
this.manager.cache.set(bt._id, bt);
|
|
109
|
-
return bt;
|
|
110
|
-
}
|
|
111
|
-
async addConfirmed(type, id) {
|
|
112
|
-
Assertion_1.Assertion.assertString(type);
|
|
113
|
-
Assertion_1.Assertion.assertString(id);
|
|
114
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "confirmed");
|
|
115
|
-
const payload = { entry: { type, id } };
|
|
116
|
-
const response = await this.rest.request({
|
|
117
|
-
method: "PATCH",
|
|
118
|
-
url: route,
|
|
119
|
-
payload,
|
|
120
|
-
});
|
|
121
|
-
this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
|
|
122
|
-
this.confirmed = response.confirmed;
|
|
123
|
-
this.manager.cache.set(this._id, this);
|
|
124
|
-
return response.confirmed.find((cn) => cn.type == type);
|
|
125
|
-
}
|
|
126
|
-
async setConfirmed(set) {
|
|
127
|
-
Assertion_1.Assertion.assertObject(set);
|
|
128
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "confirmed");
|
|
129
|
-
const response = await this.rest.request({
|
|
130
|
-
method: "PATCH",
|
|
131
|
-
url: route,
|
|
132
|
-
payload: set,
|
|
133
|
-
});
|
|
134
|
-
this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
|
|
135
|
-
this.confirmed = response.confirmed;
|
|
136
|
-
this.manager.cache.set(this._id, this);
|
|
137
|
-
return this.confirmed;
|
|
138
|
-
}
|
|
139
|
-
async setStatus(status) {
|
|
140
|
-
Assertion_1.Assertion.assertString(status);
|
|
141
|
-
const payload = { set: status.toLowerCase() };
|
|
142
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "status");
|
|
143
|
-
const response = await this.rest.request({
|
|
144
|
-
method: "PATCH",
|
|
145
|
-
url: route,
|
|
146
|
-
payload,
|
|
147
|
-
});
|
|
148
|
-
this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
|
|
149
|
-
this.status = response.status;
|
|
150
|
-
this.manager.cache.set(this._id, this);
|
|
151
|
-
return this;
|
|
152
|
-
}
|
|
153
|
-
async setWinner(userId) {
|
|
154
|
-
Assertion_1.Assertion.assertString(userId);
|
|
155
|
-
const payload = { set: userId };
|
|
156
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "winner");
|
|
157
|
-
const response = await this.rest.request({
|
|
158
|
-
method: "PATCH",
|
|
159
|
-
url: route,
|
|
160
|
-
payload,
|
|
161
|
-
});
|
|
162
|
-
this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
|
|
163
|
-
this.winner = response.winner;
|
|
164
|
-
this.manager.cache.set(this._id, this);
|
|
165
|
-
return response.winner;
|
|
166
|
-
}
|
|
167
|
-
async setLoser(userId) {
|
|
168
|
-
Assertion_1.Assertion.assertString(userId);
|
|
169
|
-
const payload = { set: userId };
|
|
170
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "loser");
|
|
171
|
-
const response = await this.rest.request({
|
|
172
|
-
method: "PATCH",
|
|
173
|
-
url: route,
|
|
174
|
-
payload,
|
|
175
|
-
});
|
|
176
|
-
this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
|
|
177
|
-
this.loser = response.loser;
|
|
178
|
-
this.manager.cache.set(this._id, this);
|
|
179
|
-
return response.loser;
|
|
180
|
-
}
|
|
181
|
-
async delete() {
|
|
182
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id);
|
|
183
|
-
const response = await this.rest.request({
|
|
184
|
-
method: "DELETE",
|
|
185
|
-
url: route,
|
|
186
|
-
});
|
|
187
|
-
this.manager.cache.delete(this?._id);
|
|
188
|
-
this.rest.bets.delete(this?._id);
|
|
189
|
-
return response;
|
|
190
|
-
}
|
|
191
|
-
async addChannel(id, type) {
|
|
192
|
-
const ch = await this.channels.create({ id, type });
|
|
193
|
-
this.manager.cache.set(this._id, this);
|
|
194
|
-
return ch;
|
|
195
|
-
}
|
|
196
|
-
async addMessage(id, type, content) {
|
|
197
|
-
const response = await this.messages.create({
|
|
198
|
-
userId: id,
|
|
199
|
-
type: type,
|
|
200
|
-
content,
|
|
201
|
-
});
|
|
202
|
-
this.manager.cache.set(this._id, this);
|
|
203
|
-
this.rest.bets.set(this._id, this);
|
|
204
|
-
return response;
|
|
205
|
-
}
|
|
206
|
-
async setChannels(channels) {
|
|
207
|
-
Assertion_1.Assertion.assertObject(channels);
|
|
208
|
-
const payload = { set: channels };
|
|
209
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "channels");
|
|
210
|
-
const response = await this.rest.request({
|
|
211
|
-
method: "PATCH",
|
|
212
|
-
url: route,
|
|
213
|
-
payload,
|
|
214
|
-
});
|
|
215
|
-
this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
|
|
216
|
-
this.channels.setAll(response.channels);
|
|
217
|
-
this.manager.cache.set(this._id, this);
|
|
218
|
-
return this.channels;
|
|
219
|
-
}
|
|
220
|
-
async addPlayer(player) {
|
|
221
|
-
Assertion_1.Assertion.assertObject(player);
|
|
222
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "players");
|
|
223
|
-
const payload = { ...player };
|
|
224
|
-
const response = await this.rest.request({
|
|
225
|
-
method: "POST",
|
|
226
|
-
url: route,
|
|
227
|
-
payload,
|
|
228
|
-
});
|
|
229
|
-
this.players = response;
|
|
230
|
-
this.manager.cache.set(this._id, this);
|
|
231
|
-
return this.players;
|
|
232
|
-
}
|
|
233
|
-
async removePlayer(player) {
|
|
234
|
-
Assertion_1.Assertion.assertObject(player);
|
|
235
|
-
const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, this._id, "players", player.id);
|
|
236
|
-
const payload = { ...player };
|
|
237
|
-
const response = await this.rest.request({
|
|
238
|
-
method: "DELETE",
|
|
239
|
-
url: route,
|
|
240
|
-
payload,
|
|
241
|
-
});
|
|
242
|
-
this.players = response;
|
|
243
|
-
this.manager.cache.set(this._id, this);
|
|
244
|
-
return this.players;
|
|
245
|
-
}
|
|
246
|
-
async update(data) {
|
|
247
|
-
const route = Routes_1.Routes.guilds.bets.get(this.guild.id, this._id);
|
|
248
|
-
const payload = data;
|
|
249
|
-
const response = await this.rest.request({
|
|
250
|
-
method: "patch",
|
|
251
|
-
url: route,
|
|
252
|
-
payload,
|
|
253
|
-
});
|
|
254
|
-
this.rest.emit("betUpdate", this, new GuildBet(response, this.guild, this.manager, this.rest));
|
|
255
|
-
for (const k in response) {
|
|
256
|
-
if (k === "id")
|
|
257
|
-
continue;
|
|
258
|
-
if (Object.hasOwn(this, k)) {
|
|
259
|
-
if (k === "channels") {
|
|
260
|
-
this.channels.setAll(response["channels"]);
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
if (k === "messages") {
|
|
264
|
-
this.messages.setAll(response["messages"]);
|
|
265
|
-
continue;
|
|
266
|
-
}
|
|
267
|
-
this[k] = response[k];
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
this.rest.bets.set(this._id, this);
|
|
271
|
-
this.manager.cache.set(this._id, this);
|
|
272
|
-
return this;
|
|
273
|
-
}
|
|
274
|
-
toJSON() {
|
|
275
|
-
const json = {};
|
|
276
|
-
for (const [key, value] of Object.entries(this)) {
|
|
277
|
-
if (typeof value !== "function") {
|
|
278
|
-
json[key] = value;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return json;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
exports.GuildBet = GuildBet;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { REST } from "../../rest/REST";
|
|
2
|
-
import { Daily, Items, Optional, ProfileCard } from "../../types/api";
|
|
3
|
-
import { APIGuildBetUser } from "../../types/api/APIGuildBetUser";
|
|
4
|
-
import { GuildBetUserManager } from "../../managers/betuser/GuildBetUserManager";
|
|
5
|
-
export declare class GuildBetUser implements APIGuildBetUser {
|
|
6
|
-
#private;
|
|
7
|
-
/** User daily */
|
|
8
|
-
daily: Omit<Daily, "points">;
|
|
9
|
-
/** User's name */
|
|
10
|
-
name: string;
|
|
11
|
-
/** User's name */
|
|
12
|
-
id: string;
|
|
13
|
-
/** User's credit */
|
|
14
|
-
credit: number;
|
|
15
|
-
/** User's wins */
|
|
16
|
-
wins: number;
|
|
17
|
-
/** User's mvps */
|
|
18
|
-
mvps: number;
|
|
19
|
-
/** User's losses */
|
|
20
|
-
losses: number;
|
|
21
|
-
/** User's bets played */
|
|
22
|
-
betsPlayed: string[];
|
|
23
|
-
/** User's blacklist */
|
|
24
|
-
blacklist: boolean;
|
|
25
|
-
/** User's coins */
|
|
26
|
-
coins: number;
|
|
27
|
-
games: number;
|
|
28
|
-
/** User's items */
|
|
29
|
-
items: Items;
|
|
30
|
-
/** User's profile card */
|
|
31
|
-
profileCard: ProfileCard;
|
|
32
|
-
/** Creation Date */
|
|
33
|
-
createdAt: Date;
|
|
34
|
-
/** Updated Date */
|
|
35
|
-
updatedAt: Date;
|
|
36
|
-
/** The given manager */
|
|
37
|
-
readonly manager: GuildBetUserManager;
|
|
38
|
-
/** The rest client */
|
|
39
|
-
readonly rest: REST;
|
|
40
|
-
/**
|
|
41
|
-
* Bet user
|
|
42
|
-
* @param data The user's data
|
|
43
|
-
* @param manager The manager
|
|
44
|
-
* @param rest The rest client
|
|
45
|
-
*/
|
|
46
|
-
constructor(data: APIGuildBetUser, manager: GuildBetUserManager, rest: REST);
|
|
47
|
-
/** String representation of this user */
|
|
48
|
-
toString(): string;
|
|
49
|
-
/**
|
|
50
|
-
* Fetches the user
|
|
51
|
-
* @returns New Instance of the user
|
|
52
|
-
*/
|
|
53
|
-
fetch(): Promise<GuildBetUser>;
|
|
54
|
-
/**
|
|
55
|
-
* Add a propery
|
|
56
|
-
* @param key The desired key
|
|
57
|
-
* @param value The desired value
|
|
58
|
-
* @returns GuildBetUser
|
|
59
|
-
*/
|
|
60
|
-
add<K extends keyof BetUserAddOptions, V extends BetUserAddOptions[K]>(key: K, value: V): Promise<this>;
|
|
61
|
-
reset(): Promise<this>;
|
|
62
|
-
/**
|
|
63
|
-
* Set the user blacklist
|
|
64
|
-
* @param value Value to set to
|
|
65
|
-
* @returns GuildBetUser
|
|
66
|
-
*/
|
|
67
|
-
setBlacklist(value: boolean): Promise<this>;
|
|
68
|
-
/**
|
|
69
|
-
* Update certain property
|
|
70
|
-
* @param data The new data to update with
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
update(data: Omit<Optional<APIGuildBetUser>, "daily"> & {
|
|
74
|
-
type?: "add" | "remove";
|
|
75
|
-
}): Promise<this>;
|
|
76
|
-
delete(): Promise<boolean>;
|
|
77
|
-
toJSON(): Record<string, unknown>;
|
|
78
|
-
}
|
|
79
|
-
export type BetUserAddOptions = {
|
|
80
|
-
coins: number;
|
|
81
|
-
credit: number;
|
|
82
|
-
wins: number;
|
|
83
|
-
losses: number;
|
|
84
|
-
mvps: number;
|
|
85
|
-
};
|