@duque.edits/sdk 0.1.4 → 0.1.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/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/managers/buffer/BufferManager.d.ts +10 -6
- package/dist/managers/buffer/BufferManager.js +6 -0
- package/dist/managers/giveaway/GiveawayManager.d.ts +16 -0
- package/dist/managers/giveaway/GiveawayManager.js +57 -0
- package/dist/managers/match/GuildMatchManager.js +2 -0
- package/dist/managers/vipmember/VipMemberManager.d.ts +33 -0
- package/dist/managers/vipmember/VipMemberManager.js +124 -0
- package/dist/rest/REST.d.ts +2 -0
- package/dist/rest/REST.js +4 -1
- package/dist/rest/Routes.d.ts +16 -0
- package/dist/rest/Routes.js +16 -0
- package/dist/structures/bet/GuildBet.js +2 -0
- package/dist/structures/giveaway/Giveaway.d.ts +37 -0
- package/dist/structures/giveaway/Giveaway.js +208 -0
- package/dist/structures/guild/Guild.d.ts +5 -0
- package/dist/structures/guild/Guild.js +17 -0
- package/dist/structures/user/GuildUser.js +2 -0
- package/dist/structures/vipmember/VipMember.d.ts +54 -0
- package/dist/structures/vipmember/VipMember.js +137 -0
- package/dist/types/api/APIGiveaway.d.ts +27 -0
- package/dist/types/api/APIGiveaway.js +2 -0
- package/dist/types/api/APIMessage.d.ts +2 -2
- package/dist/types/api/APIVipMember.d.ts +20 -0
- package/dist/types/api/APIVipMember.js +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/getRandomNumber.d.ts +1 -0
- package/dist/utils/getRandomNumber.js +6 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export * from "./managers/permission/GuildPermissionManager";
|
|
|
10
10
|
export * from "./managers/product/GuildProductManager";
|
|
11
11
|
export * from "./managers/ticket/GuildTicketManager";
|
|
12
12
|
export * from "./managers/user/GuildUserManager";
|
|
13
|
+
export * from "./managers/vipmember/VipMemberManager";
|
|
14
|
+
export * from "./managers/giveaway/GiveawayManager";
|
|
13
15
|
export * from "./structures/bet/GuildBet";
|
|
14
16
|
export * from "./structures/betuser/GuildBetUser";
|
|
15
17
|
export * from "./structures/channel/Channel";
|
|
@@ -21,6 +23,8 @@ export * from "./structures/product/GuildProduct";
|
|
|
21
23
|
export * from "./structures/shop/GuildShop";
|
|
22
24
|
export * from "./structures/ticket/GuildTicket";
|
|
23
25
|
export * from "./structures/user/GuildUser";
|
|
26
|
+
export * from "./structures/vipmember/VipMember";
|
|
27
|
+
export * from "./structures/giveaway/Giveaway";
|
|
24
28
|
export * from "./structures/Collection";
|
|
25
29
|
export * from "./rest/REST";
|
|
26
30
|
export * from "./rest/Routes";
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,8 @@ __exportStar(require("./managers/permission/GuildPermissionManager"), exports);
|
|
|
26
26
|
__exportStar(require("./managers/product/GuildProductManager"), exports);
|
|
27
27
|
__exportStar(require("./managers/ticket/GuildTicketManager"), exports);
|
|
28
28
|
__exportStar(require("./managers/user/GuildUserManager"), exports);
|
|
29
|
+
__exportStar(require("./managers/vipmember/VipMemberManager"), exports);
|
|
30
|
+
__exportStar(require("./managers/giveaway/GiveawayManager"), exports);
|
|
29
31
|
__exportStar(require("./structures/bet/GuildBet"), exports);
|
|
30
32
|
__exportStar(require("./structures/betuser/GuildBetUser"), exports);
|
|
31
33
|
__exportStar(require("./structures/channel/Channel"), exports);
|
|
@@ -37,6 +39,8 @@ __exportStar(require("./structures/product/GuildProduct"), exports);
|
|
|
37
39
|
__exportStar(require("./structures/shop/GuildShop"), exports);
|
|
38
40
|
__exportStar(require("./structures/ticket/GuildTicket"), exports);
|
|
39
41
|
__exportStar(require("./structures/user/GuildUser"), exports);
|
|
42
|
+
__exportStar(require("./structures/vipmember/VipMember"), exports);
|
|
43
|
+
__exportStar(require("./structures/giveaway/Giveaway"), exports);
|
|
40
44
|
__exportStar(require("./structures/Collection"), exports);
|
|
41
45
|
__exportStar(require("./rest/REST"), exports);
|
|
42
46
|
__exportStar(require("./rest/Routes"), exports);
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { Collection } from "../../structures/Collection";
|
|
2
2
|
import { Guild } from "../../structures/guild/Guild";
|
|
3
3
|
import { APIGuildMatch, APIGuildTicket, Optional } from "../../types";
|
|
4
|
+
export type BufferMatch = Optional<APIGuildMatch & {
|
|
5
|
+
id: string;
|
|
6
|
+
}>;
|
|
7
|
+
export type BufferTicket = Optional<APIGuildTicket & {
|
|
8
|
+
id: string;
|
|
9
|
+
}>;
|
|
4
10
|
export declare class BufferManager {
|
|
5
|
-
matches: Collection<string,
|
|
6
|
-
|
|
7
|
-
}>>;
|
|
8
|
-
tickets: Collection<string, Optional<APIGuildTicket & {
|
|
9
|
-
id: string;
|
|
10
|
-
}>>;
|
|
11
|
+
matches: Collection<string, BufferMatch>;
|
|
12
|
+
tickets: Collection<string, BufferTicket>;
|
|
11
13
|
guild: Guild;
|
|
12
14
|
constructor(guild: Guild);
|
|
13
15
|
flush(key: "matches" | "tickets"): Promise<APIGuildMatch[] & APIGuildTicket[]>;
|
|
16
|
+
createMatch(id: string, data: BufferMatch): void;
|
|
17
|
+
createTicket(id: string, data: BufferTicket): void;
|
|
14
18
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { Collection } from "../../structures/Collection";
|
|
3
|
+
import { Giveaway } from "../../structures/giveaway/Giveaway";
|
|
4
|
+
import { Optional } from "../../types";
|
|
5
|
+
import { APIGiveaway } from "../../types/api/APIGiveaway";
|
|
6
|
+
type AllowedTypes = Optional<APIGiveaway> | Giveaway | Giveaway[] | Optional<APIGiveaway>[];
|
|
7
|
+
export declare class GiveawayManager {
|
|
8
|
+
cache: Collection<String, Giveaway>;
|
|
9
|
+
readonly rest: REST;
|
|
10
|
+
constructor(rest: REST);
|
|
11
|
+
fetchAll(): Promise<Collection<String, Giveaway>>;
|
|
12
|
+
create(data: Optional<APIGiveaway>): Promise<Giveaway>;
|
|
13
|
+
deleteAll(): Promise<Collection<String, Giveaway>>;
|
|
14
|
+
set(data: AllowedTypes): void;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GiveawayManager = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const Collection_1 = require("../../structures/Collection");
|
|
6
|
+
const Giveaway_1 = require("../../structures/giveaway/Giveaway");
|
|
7
|
+
class GiveawayManager {
|
|
8
|
+
cache;
|
|
9
|
+
rest;
|
|
10
|
+
constructor(rest) {
|
|
11
|
+
this.rest = rest;
|
|
12
|
+
this.cache = new Collection_1.Collection("giveaways");
|
|
13
|
+
}
|
|
14
|
+
async fetchAll() {
|
|
15
|
+
const route = Routes_1.Routes.giveaways.getAll();
|
|
16
|
+
const response = await this.rest.request({
|
|
17
|
+
method: "get",
|
|
18
|
+
url: route,
|
|
19
|
+
});
|
|
20
|
+
this.set(response);
|
|
21
|
+
return this.cache;
|
|
22
|
+
}
|
|
23
|
+
async create(data) {
|
|
24
|
+
const route = Routes_1.Routes.giveaways.create();
|
|
25
|
+
const payload = data;
|
|
26
|
+
const response = await this.rest.request({
|
|
27
|
+
method: "post",
|
|
28
|
+
url: route,
|
|
29
|
+
payload,
|
|
30
|
+
});
|
|
31
|
+
const giveaway = new Giveaway_1.Giveaway(response, this);
|
|
32
|
+
this.set(giveaway);
|
|
33
|
+
return giveaway;
|
|
34
|
+
}
|
|
35
|
+
async deleteAll() {
|
|
36
|
+
const route = Routes_1.Routes.giveaways.deleteAll();
|
|
37
|
+
const response = await this.rest.request({
|
|
38
|
+
method: "delete",
|
|
39
|
+
url: route,
|
|
40
|
+
});
|
|
41
|
+
this.cache.clear();
|
|
42
|
+
return this.cache;
|
|
43
|
+
}
|
|
44
|
+
set(data) {
|
|
45
|
+
if (Array.isArray(data)) {
|
|
46
|
+
for (let giv of data) {
|
|
47
|
+
giv = new Giveaway_1.Giveaway(giv, this);
|
|
48
|
+
this.cache.set(giv._id, giv);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
data = new Giveaway_1.Giveaway(data, this);
|
|
53
|
+
this.cache.set(data._id, data);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.GiveawayManager = GiveawayManager;
|
|
@@ -33,6 +33,8 @@ class GuildMatchManager {
|
|
|
33
33
|
method: "get",
|
|
34
34
|
url: route,
|
|
35
35
|
});
|
|
36
|
+
if (!response.creatorId)
|
|
37
|
+
return null;
|
|
36
38
|
const match = new GuildMatch_1.GuildMatch(response, this.guild, this, this.rest);
|
|
37
39
|
this.cache.set(match._id, match);
|
|
38
40
|
this.rest.matches.set(match._id, match);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { VipMember } from "../../structures/vipmember/VipMember";
|
|
3
|
+
import { Collection } from "../../structures/Collection";
|
|
4
|
+
import { Guild } from "../../structures/guild/Guild";
|
|
5
|
+
import { APIVipMember } from "../../types/api/APIVipMember";
|
|
6
|
+
import { Optional } from "../../types";
|
|
7
|
+
export declare class VipMemberManager {
|
|
8
|
+
/** A cache of vipmembers */
|
|
9
|
+
cache: Collection<string, VipMember>;
|
|
10
|
+
/** The rest client */
|
|
11
|
+
readonly rest: REST;
|
|
12
|
+
readonly guild: Guild;
|
|
13
|
+
/**
|
|
14
|
+
* Manage vipmembers with the given client
|
|
15
|
+
* @param vipmembers An array of vipmembers
|
|
16
|
+
* @param rest The rest client
|
|
17
|
+
*/
|
|
18
|
+
constructor(guild: Guild, rest: REST);
|
|
19
|
+
create(data: Optional<APIVipMember>): Promise<VipMember>;
|
|
20
|
+
/**
|
|
21
|
+
* Fetch a member
|
|
22
|
+
* @param id Id of the member to fetch
|
|
23
|
+
* @returns VipMember
|
|
24
|
+
*/
|
|
25
|
+
fetch(id: string): Promise<VipMember>;
|
|
26
|
+
fetchAll(): Promise<Collection<string, VipMember>>;
|
|
27
|
+
updateMember(id: string, data: Optional<APIVipMember>): Promise<VipMember>;
|
|
28
|
+
set(data: APIVipMember): VipMember;
|
|
29
|
+
setAll(data: APIVipMember[]): Collection<string, VipMember>;
|
|
30
|
+
resetAll(): Promise<Collection<string, VipMember>>;
|
|
31
|
+
delete(id: string): Promise<Collection<string, VipMember>>;
|
|
32
|
+
deleteAll(): Promise<boolean>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VipMemberManager = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const VipMember_1 = require("../../structures/vipmember/VipMember");
|
|
6
|
+
const Collection_1 = require("../../structures/Collection");
|
|
7
|
+
const Assertion_1 = require("../../utils/Assertion");
|
|
8
|
+
class VipMemberManager {
|
|
9
|
+
/** A cache of vipmembers */
|
|
10
|
+
cache;
|
|
11
|
+
/** The rest client */
|
|
12
|
+
rest;
|
|
13
|
+
guild;
|
|
14
|
+
/**
|
|
15
|
+
* Manage vipmembers with the given client
|
|
16
|
+
* @param vipmembers An array of vipmembers
|
|
17
|
+
* @param rest The rest client
|
|
18
|
+
*/
|
|
19
|
+
constructor(guild, rest) {
|
|
20
|
+
this.rest = rest;
|
|
21
|
+
this.guild = guild;
|
|
22
|
+
this.cache = new Collection_1.Collection("vipmembers");
|
|
23
|
+
}
|
|
24
|
+
async create(data) {
|
|
25
|
+
const route = Routes_1.Routes.vipmembers.create(this.guild.id);
|
|
26
|
+
const payload = { ...data };
|
|
27
|
+
const response = await this.rest.request({
|
|
28
|
+
method: "post",
|
|
29
|
+
url: route,
|
|
30
|
+
payload,
|
|
31
|
+
});
|
|
32
|
+
const member = new VipMember_1.VipMember(response, this, this.rest);
|
|
33
|
+
this.cache.set(member?.id, member);
|
|
34
|
+
return member;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Fetch a member
|
|
38
|
+
* @param id Id of the member to fetch
|
|
39
|
+
* @returns VipMember
|
|
40
|
+
*/
|
|
41
|
+
async fetch(id) {
|
|
42
|
+
const route = Routes_1.Routes.vipmembers.get(this.guild.id, id);
|
|
43
|
+
const payload = { guild_id: this.guild.id };
|
|
44
|
+
const response = await this.rest.request({
|
|
45
|
+
method: "get",
|
|
46
|
+
url: route,
|
|
47
|
+
payload,
|
|
48
|
+
});
|
|
49
|
+
if (!response)
|
|
50
|
+
return this.cache.get(id);
|
|
51
|
+
const member = new VipMember_1.VipMember(response, this, this.rest);
|
|
52
|
+
this.cache.set(member?.id, member);
|
|
53
|
+
return member;
|
|
54
|
+
}
|
|
55
|
+
async fetchAll() {
|
|
56
|
+
const route = Routes_1.Routes.vipmembers.getAll(this.guild.id);
|
|
57
|
+
const response = await this.rest.request({
|
|
58
|
+
method: "get",
|
|
59
|
+
url: route,
|
|
60
|
+
});
|
|
61
|
+
if (Array.isArray(response) && response.length === 0) {
|
|
62
|
+
this.cache.clear();
|
|
63
|
+
return this.cache;
|
|
64
|
+
}
|
|
65
|
+
this.setAll(response);
|
|
66
|
+
return this.cache;
|
|
67
|
+
}
|
|
68
|
+
async updateMember(id, data) {
|
|
69
|
+
const route = Routes_1.Routes.vipmembers.update(this.guild.id, id);
|
|
70
|
+
const payload = { ...data, guild_id: this.guild.id };
|
|
71
|
+
const response = await this.rest.request({
|
|
72
|
+
method: "Patch",
|
|
73
|
+
url: route,
|
|
74
|
+
payload,
|
|
75
|
+
});
|
|
76
|
+
const member = this.set(response);
|
|
77
|
+
return member;
|
|
78
|
+
}
|
|
79
|
+
set(data) {
|
|
80
|
+
if (!data?.id)
|
|
81
|
+
return;
|
|
82
|
+
const member = new VipMember_1.VipMember(data, this, this.rest);
|
|
83
|
+
this.cache.set(member.id, member);
|
|
84
|
+
return member;
|
|
85
|
+
}
|
|
86
|
+
setAll(data) {
|
|
87
|
+
if (!data)
|
|
88
|
+
return this.cache;
|
|
89
|
+
for (let member of data)
|
|
90
|
+
this.set(member);
|
|
91
|
+
return this.cache;
|
|
92
|
+
}
|
|
93
|
+
async resetAll() {
|
|
94
|
+
const route = Routes_1.Routes.vipmembers.getAll(this.guild.id);
|
|
95
|
+
const response = await this.rest.request({
|
|
96
|
+
method: "PUT",
|
|
97
|
+
url: route,
|
|
98
|
+
});
|
|
99
|
+
this.setAll(response);
|
|
100
|
+
return this.cache;
|
|
101
|
+
}
|
|
102
|
+
async delete(id) {
|
|
103
|
+
Assertion_1.Assertion.assertString(id);
|
|
104
|
+
Assertion_1.Assertion.assertString(this.guild.id);
|
|
105
|
+
const route = Routes_1.Routes.vipmembers.delete(id, this.guild.id);
|
|
106
|
+
await this.rest.request({
|
|
107
|
+
method: "DELETE",
|
|
108
|
+
url: route,
|
|
109
|
+
});
|
|
110
|
+
this.cache.delete(id);
|
|
111
|
+
return this.cache;
|
|
112
|
+
}
|
|
113
|
+
async deleteAll() {
|
|
114
|
+
Assertion_1.Assertion.assertString(this.guild.id);
|
|
115
|
+
const route = Routes_1.Routes.vipmembers.deleteAll(this.guild.id);
|
|
116
|
+
const value = await this.rest.request({
|
|
117
|
+
method: "DELETE",
|
|
118
|
+
url: route,
|
|
119
|
+
});
|
|
120
|
+
this.cache.clear();
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.VipMemberManager = VipMemberManager;
|
package/dist/rest/REST.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { GuildBetUser } from "../structures/betuser/GuildBetUser";
|
|
|
6
6
|
import { GuildMatch } from "../structures/match/GuildMatch";
|
|
7
7
|
import { GuildMediator } from "../structures/mediator/GuildMediator";
|
|
8
8
|
import { GuildUser } from "../structures/user/GuildUser";
|
|
9
|
+
import { GiveawayManager } from "../managers/giveaway/GiveawayManager";
|
|
9
10
|
interface RequestOptions<Payload> {
|
|
10
11
|
/** The request's method */
|
|
11
12
|
method: string;
|
|
@@ -24,6 +25,7 @@ export declare class REST extends EventEmitter {
|
|
|
24
25
|
key: string;
|
|
25
26
|
/** The guild manager */
|
|
26
27
|
guilds: GuildManager;
|
|
28
|
+
giveaways: GiveawayManager;
|
|
27
29
|
bets: Collection<string, GuildBet>;
|
|
28
30
|
matches: Collection<string, GuildMatch>;
|
|
29
31
|
betUsers: Collection<string, GuildBetUser>;
|
package/dist/rest/REST.js
CHANGED
|
@@ -11,6 +11,7 @@ const Routes_1 = require("./Routes");
|
|
|
11
11
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
12
12
|
const GuildManager_1 = require("../managers/guild/GuildManager");
|
|
13
13
|
const Collection_1 = require("../structures/Collection");
|
|
14
|
+
const GiveawayManager_1 = require("../managers/giveaway/GiveawayManager");
|
|
14
15
|
dotenv_1.default.config();
|
|
15
16
|
const Reset = "\x1b[0m";
|
|
16
17
|
const FgGreen = "\x1b[32m";
|
|
@@ -27,6 +28,7 @@ class REST extends events_1.default {
|
|
|
27
28
|
key;
|
|
28
29
|
/** The guild manager */
|
|
29
30
|
guilds;
|
|
31
|
+
giveaways;
|
|
30
32
|
bets;
|
|
31
33
|
matches;
|
|
32
34
|
betUsers;
|
|
@@ -43,6 +45,7 @@ class REST extends events_1.default {
|
|
|
43
45
|
this.key = key;
|
|
44
46
|
}
|
|
45
47
|
this.guilds = new GuildManager_1.GuildManager(this);
|
|
48
|
+
this.giveaways = new GiveawayManager_1.GiveawayManager(this);
|
|
46
49
|
this.bets = new Collection_1.Collection("bets");
|
|
47
50
|
this.matches = new Collection_1.Collection("matches");
|
|
48
51
|
this.betUsers = new Collection_1.Collection("betUsers");
|
|
@@ -58,7 +61,7 @@ class REST extends events_1.default {
|
|
|
58
61
|
}
|
|
59
62
|
/** Initialize the caching sistem */
|
|
60
63
|
async init() {
|
|
61
|
-
await this.guilds.fetchAll();
|
|
64
|
+
await Promise.all([this.guilds.fetchAll(), this.giveaways.fetchAll()]);
|
|
62
65
|
return this;
|
|
63
66
|
}
|
|
64
67
|
/**
|
package/dist/rest/Routes.d.ts
CHANGED
|
@@ -81,4 +81,20 @@ export declare const Routes: {
|
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
|
+
vipmembers: {
|
|
85
|
+
get: (guildId: string, memberId: string) => string;
|
|
86
|
+
getAll: (guildId: string) => string;
|
|
87
|
+
deleteAll: (guildId: string) => string;
|
|
88
|
+
create: (guildId: string) => string;
|
|
89
|
+
update: (guildId: string, memberId: string) => string;
|
|
90
|
+
delete: (guildId: string, memberId: string) => string;
|
|
91
|
+
};
|
|
92
|
+
giveaways: {
|
|
93
|
+
get: (giveawayId: string) => string;
|
|
94
|
+
getAll: () => string;
|
|
95
|
+
deleteAll: () => string;
|
|
96
|
+
create: () => string;
|
|
97
|
+
update: (giveawayId: string) => string;
|
|
98
|
+
delete: (giveawayId: string) => string;
|
|
99
|
+
};
|
|
84
100
|
};
|
package/dist/rest/Routes.js
CHANGED
|
@@ -86,4 +86,20 @@ exports.Routes = {
|
|
|
86
86
|
},
|
|
87
87
|
},
|
|
88
88
|
},
|
|
89
|
+
vipmembers: {
|
|
90
|
+
get: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
|
|
91
|
+
getAll: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
92
|
+
deleteAll: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
93
|
+
create: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
94
|
+
update: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
|
|
95
|
+
delete: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
|
|
96
|
+
},
|
|
97
|
+
giveaways: {
|
|
98
|
+
get: (giveawayId) => `/giveaways/${giveawayId}`,
|
|
99
|
+
getAll: () => `/giveaways`,
|
|
100
|
+
deleteAll: () => `/giveaways`,
|
|
101
|
+
create: () => `/giveaways`,
|
|
102
|
+
update: (giveawayId) => `/giveaways/${giveawayId}`,
|
|
103
|
+
delete: (giveawayId) => `/giveaways/${giveawayId}`,
|
|
104
|
+
},
|
|
89
105
|
};
|
|
@@ -269,6 +269,8 @@ class GuildBet {
|
|
|
269
269
|
}
|
|
270
270
|
this.rest.bets.set(this._id, this);
|
|
271
271
|
this.manager.cache.set(this._id, this);
|
|
272
|
+
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
273
|
+
this.createdAt = response?.createdAt ? new Date(response?.createdAt) : new Date();
|
|
272
274
|
return this;
|
|
273
275
|
}
|
|
274
276
|
toJSON() {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { GiveawayManager } from "../../managers/giveaway/GiveawayManager";
|
|
2
|
+
import { REST } from "../../rest/REST";
|
|
3
|
+
import { Optional } from "../../types";
|
|
4
|
+
import { APIGiveaway, GiveawayMessage, GiveawayWinners } from "../../types/api/APIGiveaway";
|
|
5
|
+
type AllowedTypes = Optional<APIGiveaway> | Giveaway;
|
|
6
|
+
export declare class Giveaway {
|
|
7
|
+
host_id: string;
|
|
8
|
+
channel_id: string;
|
|
9
|
+
guild_id: string;
|
|
10
|
+
_id: string;
|
|
11
|
+
/** Duration of giveaway in sec */
|
|
12
|
+
duration: number;
|
|
13
|
+
prizes: string[];
|
|
14
|
+
participants: string[];
|
|
15
|
+
allowed_roles: string[];
|
|
16
|
+
blacklisted_roles: string[];
|
|
17
|
+
message: GiveawayMessage;
|
|
18
|
+
winners: GiveawayWinners;
|
|
19
|
+
rerolls: string[];
|
|
20
|
+
status: "created" | "off" | "on";
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
readonly rest: REST;
|
|
24
|
+
readonly manager: GiveawayManager;
|
|
25
|
+
constructor(data: AllowedTypes, manager: GiveawayManager);
|
|
26
|
+
end(): Promise<boolean>;
|
|
27
|
+
start(): Promise<boolean>;
|
|
28
|
+
addAllowedRole(roleId: string): Promise<boolean>;
|
|
29
|
+
addBlacklistedRole(roleId: string): Promise<boolean>;
|
|
30
|
+
getWinners(): Promise<this>;
|
|
31
|
+
addParticipant(userId: string): Promise<this>;
|
|
32
|
+
removeParticipant(userId: string): Promise<this>;
|
|
33
|
+
reroll(winners?: string[]): Promise<this>;
|
|
34
|
+
delete(): Promise<boolean>;
|
|
35
|
+
update(data: AllowedTypes): Promise<this>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Giveaway = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const getRandomNumber_1 = require("../../utils/getRandomNumber");
|
|
6
|
+
class Giveaway {
|
|
7
|
+
host_id;
|
|
8
|
+
channel_id;
|
|
9
|
+
guild_id;
|
|
10
|
+
_id;
|
|
11
|
+
/** Duration of giveaway in sec */
|
|
12
|
+
duration;
|
|
13
|
+
prizes;
|
|
14
|
+
participants;
|
|
15
|
+
allowed_roles;
|
|
16
|
+
blacklisted_roles;
|
|
17
|
+
message;
|
|
18
|
+
winners;
|
|
19
|
+
rerolls;
|
|
20
|
+
status;
|
|
21
|
+
createdAt;
|
|
22
|
+
updatedAt;
|
|
23
|
+
rest;
|
|
24
|
+
manager;
|
|
25
|
+
constructor(data, manager) {
|
|
26
|
+
this._id = data?._id;
|
|
27
|
+
this.host_id = data?.host_id;
|
|
28
|
+
this.channel_id = data?.channel_id;
|
|
29
|
+
this.guild_id = data?.guild_id;
|
|
30
|
+
this.status = data?.status;
|
|
31
|
+
/** Duration of giveaway in sec */
|
|
32
|
+
this.duration = data?.duration;
|
|
33
|
+
this.prizes = data?.prizes;
|
|
34
|
+
this.participants = data?.participants;
|
|
35
|
+
this.allowed_roles = data?.allowed_roles;
|
|
36
|
+
this.blacklisted_roles = data?.blacklisted_roles;
|
|
37
|
+
this.message = data?.message;
|
|
38
|
+
this.winners = data?.winners;
|
|
39
|
+
this.rerolls = data?.rerolls;
|
|
40
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
41
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
42
|
+
this.manager = manager;
|
|
43
|
+
this.rest = manager.rest;
|
|
44
|
+
}
|
|
45
|
+
async end() {
|
|
46
|
+
const route = Routes_1.Routes.giveaways.get(this._id);
|
|
47
|
+
const payload = { status: "off" };
|
|
48
|
+
const response = await this.rest.request({
|
|
49
|
+
method: "patch",
|
|
50
|
+
url: route,
|
|
51
|
+
payload,
|
|
52
|
+
});
|
|
53
|
+
for (const k in response) {
|
|
54
|
+
if (k === "id")
|
|
55
|
+
continue;
|
|
56
|
+
if (Object.hasOwn(this, k)) {
|
|
57
|
+
this[k] = response[k];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
this.manager.set(this);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
async start() {
|
|
64
|
+
const route = Routes_1.Routes.giveaways.get(this._id);
|
|
65
|
+
const payload = { status: "on" };
|
|
66
|
+
const response = await this.rest.request({
|
|
67
|
+
method: "patch",
|
|
68
|
+
url: route,
|
|
69
|
+
payload,
|
|
70
|
+
});
|
|
71
|
+
for (const k in response) {
|
|
72
|
+
if (k === "id")
|
|
73
|
+
continue;
|
|
74
|
+
if (Object.hasOwn(this, k)) {
|
|
75
|
+
this[k] = response[k];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.manager.set(this);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
async addAllowedRole(roleId) {
|
|
82
|
+
const route = Routes_1.Routes.giveaways.get(this._id);
|
|
83
|
+
const payload = { allowed_roles: [...new Set([...this.allowed_roles, roleId])] };
|
|
84
|
+
const response = await this.rest.request({
|
|
85
|
+
method: "patch",
|
|
86
|
+
url: route,
|
|
87
|
+
payload,
|
|
88
|
+
});
|
|
89
|
+
for (const k in response) {
|
|
90
|
+
if (k === "id")
|
|
91
|
+
continue;
|
|
92
|
+
if (Object.hasOwn(this, k)) {
|
|
93
|
+
this[k] = response[k];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
this.manager.set(this);
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
async addBlacklistedRole(roleId) {
|
|
100
|
+
const route = Routes_1.Routes.giveaways.get(this._id);
|
|
101
|
+
const payload = { blacklisted_roles: [...new Set([...this.blacklisted_roles, roleId])] };
|
|
102
|
+
const response = await this.rest.request({
|
|
103
|
+
method: "patch",
|
|
104
|
+
url: route,
|
|
105
|
+
payload,
|
|
106
|
+
});
|
|
107
|
+
for (const k in response) {
|
|
108
|
+
if (k === "id")
|
|
109
|
+
continue;
|
|
110
|
+
if (Object.hasOwn(this, k)) {
|
|
111
|
+
this[k] = response[k];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
this.manager.set(this);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
async getWinners() {
|
|
118
|
+
let winners;
|
|
119
|
+
if (this.participants.length !== 0) {
|
|
120
|
+
for (let index = 0; index < this.participants.length; index++) {
|
|
121
|
+
const winnerIndex = (0, getRandomNumber_1.getRandomNumber)(1, this.participants.length ?? 1);
|
|
122
|
+
winners.push(this.participants[winnerIndex]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else
|
|
126
|
+
winners = [];
|
|
127
|
+
const newWinners = { count: winners.length, selected: winners };
|
|
128
|
+
this.winners = newWinners;
|
|
129
|
+
const route = Routes_1.Routes.giveaways.get(this._id);
|
|
130
|
+
const payload = { winners: newWinners };
|
|
131
|
+
const response = await this.rest.request({
|
|
132
|
+
method: "patch",
|
|
133
|
+
url: route,
|
|
134
|
+
payload,
|
|
135
|
+
});
|
|
136
|
+
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
137
|
+
this.manager.set(this);
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
async addParticipant(userId) {
|
|
141
|
+
const route = Routes_1.Routes.fields(Routes_1.Routes.giveaways.get(this._id), "participants");
|
|
142
|
+
const payload = { userId };
|
|
143
|
+
const response = await this.rest.request({
|
|
144
|
+
method: "post",
|
|
145
|
+
url: route,
|
|
146
|
+
payload,
|
|
147
|
+
});
|
|
148
|
+
this.participants = response.participants;
|
|
149
|
+
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
150
|
+
this.manager.set(this);
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
async removeParticipant(userId) {
|
|
154
|
+
const route = Routes_1.Routes.fields(Routes_1.Routes.giveaways.get(this._id), "participants");
|
|
155
|
+
const payload = { userId };
|
|
156
|
+
const response = await this.rest.request({
|
|
157
|
+
method: "delete",
|
|
158
|
+
url: route,
|
|
159
|
+
payload,
|
|
160
|
+
});
|
|
161
|
+
this.participants = response.participants;
|
|
162
|
+
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
163
|
+
this.manager.set(this);
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
async reroll(winners) {
|
|
167
|
+
const route = Routes_1.Routes.fields(Routes_1.Routes.giveaways.get(this._id), "rerolls");
|
|
168
|
+
const payload = { winners };
|
|
169
|
+
const response = await this.rest.request({
|
|
170
|
+
method: "post",
|
|
171
|
+
url: route,
|
|
172
|
+
payload,
|
|
173
|
+
});
|
|
174
|
+
this.rerolls = response.rerolls;
|
|
175
|
+
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
176
|
+
this.manager.set(this);
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
async delete() {
|
|
180
|
+
const route = Routes_1.Routes.giveaways.delete(this._id);
|
|
181
|
+
const response = await this.rest.request({
|
|
182
|
+
method: "delete",
|
|
183
|
+
url: route,
|
|
184
|
+
});
|
|
185
|
+
this.manager.cache.delete(this._id);
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
async update(data) {
|
|
189
|
+
const route = Routes_1.Routes.giveaways.update(this._id);
|
|
190
|
+
const payload = data;
|
|
191
|
+
const response = await this.rest.request({
|
|
192
|
+
method: "patch",
|
|
193
|
+
url: route,
|
|
194
|
+
payload,
|
|
195
|
+
});
|
|
196
|
+
for (const k in response) {
|
|
197
|
+
if (k === "id")
|
|
198
|
+
continue;
|
|
199
|
+
if (Object.hasOwn(this, k)) {
|
|
200
|
+
this[k] = response[k];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
204
|
+
this.manager.set(this);
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.Giveaway = Giveaway;
|
|
@@ -8,6 +8,7 @@ import { MessagesManager } from "../../managers/messages/MessagesManager";
|
|
|
8
8
|
import { GuildPermissionManager } from "../../managers/permission/GuildPermissionManager";
|
|
9
9
|
import { GuildTicketManager } from "../../managers/ticket/GuildTicketManager";
|
|
10
10
|
import { GuildUserManager } from "../../managers/user/GuildUserManager";
|
|
11
|
+
import { VipMemberManager } from "../../managers/vipmember/VipMemberManager";
|
|
11
12
|
import { REST } from "../../rest/REST";
|
|
12
13
|
import { Daily, GuildBlacklist } from "../../types/api";
|
|
13
14
|
import { APIGuild, DailyCategories, GuildPrices, GuildScores, GuildStatus, GuildTicketConfiguration } from "../../types/api/APIGuild";
|
|
@@ -77,6 +78,7 @@ export declare class Guild {
|
|
|
77
78
|
shop: GuildShop;
|
|
78
79
|
permissionsManager: GuildPermissionManager;
|
|
79
80
|
buffer: BufferManager;
|
|
81
|
+
vipMembers: VipMemberManager;
|
|
80
82
|
/**
|
|
81
83
|
* The guild structure
|
|
82
84
|
* @param data The guild's data
|
|
@@ -91,4 +93,7 @@ export declare class Guild {
|
|
|
91
93
|
setPrefix(prefix: string): Promise<this>;
|
|
92
94
|
addDailyCategory(category: keyof Daily): Promise<this>;
|
|
93
95
|
removeDailyCategory(category: keyof Daily): Promise<this>;
|
|
96
|
+
setScore(name: AvailableScores, amount: number): Promise<this>;
|
|
94
97
|
}
|
|
98
|
+
type AvailableScores = "win" | "loss" | "mvp" | "creator" | "coin";
|
|
99
|
+
export {};
|
|
@@ -11,6 +11,7 @@ const MessagesManager_1 = require("../../managers/messages/MessagesManager");
|
|
|
11
11
|
const GuildPermissionManager_1 = require("../../managers/permission/GuildPermissionManager");
|
|
12
12
|
const GuildTicketManager_1 = require("../../managers/ticket/GuildTicketManager");
|
|
13
13
|
const GuildUserManager_1 = require("../../managers/user/GuildUserManager");
|
|
14
|
+
const VipMemberManager_1 = require("../../managers/vipmember/VipMemberManager");
|
|
14
15
|
const Routes_1 = require("../../rest/Routes");
|
|
15
16
|
const Assertion_1 = require("../../utils/Assertion");
|
|
16
17
|
const GuildShop_1 = require("../shop/GuildShop");
|
|
@@ -74,6 +75,7 @@ class Guild {
|
|
|
74
75
|
shop;
|
|
75
76
|
permissionsManager;
|
|
76
77
|
buffer;
|
|
78
|
+
vipMembers;
|
|
77
79
|
/**
|
|
78
80
|
* The guild structure
|
|
79
81
|
* @param data The guild's data
|
|
@@ -117,6 +119,7 @@ class Guild {
|
|
|
117
119
|
this.categories = new GroupedChannelManager_1.GroupedChannelManager(this, "categories", rest);
|
|
118
120
|
this.tickets = new GuildTicketManager_1.GuildTicketManager(this, rest);
|
|
119
121
|
this.permissionsManager = new GuildPermissionManager_1.GuildPermissionManager(this, rest);
|
|
122
|
+
this.vipMembers = new VipMemberManager_1.VipMemberManager(this, rest);
|
|
120
123
|
this.buffer = new BufferManager_1.BufferManager(this);
|
|
121
124
|
this.bets.setAll(data?.bets);
|
|
122
125
|
this.users.setAll(data?.users);
|
|
@@ -128,6 +131,7 @@ class Guild {
|
|
|
128
131
|
this.tickets.setAll(data?.tickets);
|
|
129
132
|
this.permissionsManager.setAll(data?.permissions);
|
|
130
133
|
this.messages.setAll(data?.messages);
|
|
134
|
+
this.vipMembers.fetchAll();
|
|
131
135
|
}
|
|
132
136
|
async fetch() {
|
|
133
137
|
const route = Routes_1.Routes.guilds.get(this.id);
|
|
@@ -253,5 +257,18 @@ class Guild {
|
|
|
253
257
|
this.rest.emit("guildUpdate", this);
|
|
254
258
|
return this;
|
|
255
259
|
}
|
|
260
|
+
async setScore(name, amount) {
|
|
261
|
+
const route = Routes_1.Routes.fields(Routes_1.Routes.guilds.resources(this.id, "scores", name));
|
|
262
|
+
const payload = { amount };
|
|
263
|
+
const response = await this.rest.request({
|
|
264
|
+
method: "patch",
|
|
265
|
+
url: route,
|
|
266
|
+
payload,
|
|
267
|
+
});
|
|
268
|
+
this.scores = response;
|
|
269
|
+
this.rest.guilds.cache.set(this.id, this);
|
|
270
|
+
this.rest.emit("guildUpdate", this);
|
|
271
|
+
return this;
|
|
272
|
+
}
|
|
256
273
|
}
|
|
257
274
|
exports.Guild = Guild;
|
|
@@ -201,6 +201,8 @@ class GuildUser {
|
|
|
201
201
|
this[k] = response[k];
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
205
|
+
this.createdAt = response?.createdAt ? new Date(response?.createdAt) : new Date();
|
|
204
206
|
this.rest.users.set(this.id, this);
|
|
205
207
|
this.manager.cache.set(this.id, this);
|
|
206
208
|
return this;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { Optional } from "../../types/api";
|
|
3
|
+
import { APIVipMember } from "../../types/api/APIVipMember";
|
|
4
|
+
import { VipMemberManager } from "../../managers/vipmember/VipMemberManager";
|
|
5
|
+
import { Guild } from "../guild/Guild";
|
|
6
|
+
export declare class VipMember implements APIVipMember {
|
|
7
|
+
#private;
|
|
8
|
+
/** member's id */
|
|
9
|
+
id: string;
|
|
10
|
+
/** member name */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Members's roleId */
|
|
13
|
+
roleId: string;
|
|
14
|
+
/** Members's voiceChannelId */
|
|
15
|
+
voiceChannelId: string;
|
|
16
|
+
/** Vip's type */
|
|
17
|
+
type: "both" | "role" | "channel";
|
|
18
|
+
/** Member's Guild Id */
|
|
19
|
+
guild_id: string;
|
|
20
|
+
duration: Date;
|
|
21
|
+
status: "on" | "off";
|
|
22
|
+
/** member's daily */
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
/** Updated Date */
|
|
25
|
+
updatedAt: Date;
|
|
26
|
+
/** The given manager */
|
|
27
|
+
readonly manager: VipMemberManager;
|
|
28
|
+
/** The rest client */
|
|
29
|
+
readonly rest: REST;
|
|
30
|
+
readonly guild: Guild;
|
|
31
|
+
/**
|
|
32
|
+
* Bet member
|
|
33
|
+
* @param data The member's data
|
|
34
|
+
* @param manager The manager
|
|
35
|
+
* @param rest The rest client
|
|
36
|
+
*/
|
|
37
|
+
constructor(data: APIVipMember, manager: VipMemberManager, rest: REST);
|
|
38
|
+
/** String representation of this member */
|
|
39
|
+
toString(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Fetches the member
|
|
42
|
+
* @returns New Instance of the member
|
|
43
|
+
*/
|
|
44
|
+
fetch(): Promise<VipMember>;
|
|
45
|
+
reset(): Promise<this>;
|
|
46
|
+
/**
|
|
47
|
+
* Update certain property
|
|
48
|
+
* @param data The new data to update with
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
update(data: Optional<APIVipMember>): Promise<this>;
|
|
52
|
+
delete(): Promise<boolean>;
|
|
53
|
+
toJSON(): Record<keyof APIVipMember, unknown>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VipMember = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
class VipMember {
|
|
6
|
+
/** member's id */
|
|
7
|
+
id;
|
|
8
|
+
/** member name */
|
|
9
|
+
name;
|
|
10
|
+
/** Members's roleId */
|
|
11
|
+
roleId;
|
|
12
|
+
/** Members's voiceChannelId */
|
|
13
|
+
voiceChannelId;
|
|
14
|
+
/** Vip's type */
|
|
15
|
+
type;
|
|
16
|
+
/** Member's Guild Id */
|
|
17
|
+
guild_id;
|
|
18
|
+
duration;
|
|
19
|
+
status;
|
|
20
|
+
/** member's daily */
|
|
21
|
+
createdAt;
|
|
22
|
+
/** Updated Date */
|
|
23
|
+
updatedAt;
|
|
24
|
+
/** The given manager */
|
|
25
|
+
manager;
|
|
26
|
+
/** The rest client */
|
|
27
|
+
rest;
|
|
28
|
+
guild;
|
|
29
|
+
/**
|
|
30
|
+
* Bet member
|
|
31
|
+
* @param data The member's data
|
|
32
|
+
* @param manager The manager
|
|
33
|
+
* @param rest The rest client
|
|
34
|
+
*/
|
|
35
|
+
constructor(data, manager, rest) {
|
|
36
|
+
this.name = data?.name;
|
|
37
|
+
this.id = data?.id;
|
|
38
|
+
this.duration = data?.duration ? new Date(data?.duration) : new Date();
|
|
39
|
+
this.status = data?.status;
|
|
40
|
+
this.type = data?.type;
|
|
41
|
+
this.roleId = data?.roleId;
|
|
42
|
+
this.voiceChannelId = data?.voiceChannelId;
|
|
43
|
+
this.guild_id = data?.guild_id;
|
|
44
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
45
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
46
|
+
this.manager = manager;
|
|
47
|
+
this.rest = rest;
|
|
48
|
+
this.guild = manager.guild;
|
|
49
|
+
}
|
|
50
|
+
/** String representation of this member */
|
|
51
|
+
toString() {
|
|
52
|
+
return `<@${this.id}>`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Fetches the member
|
|
56
|
+
* @returns New Instance of the member
|
|
57
|
+
*/
|
|
58
|
+
async fetch() {
|
|
59
|
+
const route = Routes_1.Routes.vipmembers.get(this.guild_id, this.id);
|
|
60
|
+
const response = await this.rest.request({
|
|
61
|
+
method: "get",
|
|
62
|
+
url: route,
|
|
63
|
+
});
|
|
64
|
+
const member = new VipMember(response, this.manager, this.rest);
|
|
65
|
+
this.manager.cache.set(member.id, member);
|
|
66
|
+
return member;
|
|
67
|
+
}
|
|
68
|
+
async reset() {
|
|
69
|
+
const route = Routes_1.Routes.vipmembers.get(this.guild_id, this.id);
|
|
70
|
+
const payload = { reset: true };
|
|
71
|
+
const response = await this.rest.request({
|
|
72
|
+
method: "DELETE",
|
|
73
|
+
url: route,
|
|
74
|
+
payload,
|
|
75
|
+
});
|
|
76
|
+
this.#updateData(response);
|
|
77
|
+
this.type = response.type;
|
|
78
|
+
this.manager.set(response);
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
#updateData(data) {
|
|
82
|
+
for (const k in data) {
|
|
83
|
+
if (k === "id")
|
|
84
|
+
continue;
|
|
85
|
+
if (Object.hasOwn(this, k)) {
|
|
86
|
+
this[k] = data[k];
|
|
87
|
+
this.data[k] = data[k];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Update certain property
|
|
93
|
+
* @param data The new data to update with
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
async update(data) {
|
|
97
|
+
const route = Routes_1.Routes.vipmembers.get(this.guild.id, this.id);
|
|
98
|
+
const payload = data;
|
|
99
|
+
const response = await this.rest.request({
|
|
100
|
+
method: "patch",
|
|
101
|
+
url: route,
|
|
102
|
+
payload,
|
|
103
|
+
});
|
|
104
|
+
for (const k in response) {
|
|
105
|
+
if (k === "id")
|
|
106
|
+
continue;
|
|
107
|
+
if (Object.hasOwn(this, k)) {
|
|
108
|
+
this[k] = response[k];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
|
|
112
|
+
this.duration = response?.duration ? new Date(response?.duration) : new Date();
|
|
113
|
+
this.createdAt = response?.createdAt ? new Date(response?.createdAt) : new Date();
|
|
114
|
+
this.type = response.type;
|
|
115
|
+
this.manager.cache.set(this.id, this);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
async delete() {
|
|
119
|
+
const route = Routes_1.Routes.vipmembers.delete(this.guild_id, this.id);
|
|
120
|
+
const response = await this.rest.request({
|
|
121
|
+
method: "DELETE",
|
|
122
|
+
url: route,
|
|
123
|
+
});
|
|
124
|
+
this.manager.cache.delete(this.id);
|
|
125
|
+
return response;
|
|
126
|
+
}
|
|
127
|
+
toJSON() {
|
|
128
|
+
let json;
|
|
129
|
+
for (const [key, value] of Object.entries(this)) {
|
|
130
|
+
if (typeof value !== "function") {
|
|
131
|
+
json[key] = value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return json;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.VipMember = VipMember;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface GiveawayMessage {
|
|
2
|
+
id: string;
|
|
3
|
+
content: string;
|
|
4
|
+
type: "embed" | "text";
|
|
5
|
+
}
|
|
6
|
+
export interface GiveawayWinners {
|
|
7
|
+
count: number;
|
|
8
|
+
selected: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface APIGiveaway {
|
|
11
|
+
_id: string;
|
|
12
|
+
host_id: string;
|
|
13
|
+
channel_id: string;
|
|
14
|
+
guild_id: string;
|
|
15
|
+
/** Duration of giveaway in sec */
|
|
16
|
+
duration: number;
|
|
17
|
+
prizes: string[];
|
|
18
|
+
participants: string[];
|
|
19
|
+
allowed_roles: string[];
|
|
20
|
+
blacklisted_roles: string[];
|
|
21
|
+
message: GiveawayMessage;
|
|
22
|
+
winners: GiveawayWinners;
|
|
23
|
+
rerolls: string[];
|
|
24
|
+
status: "created" | "off" | "on";
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface APIVipMember {
|
|
2
|
+
/** Members's name */
|
|
3
|
+
name: string;
|
|
4
|
+
/** Members's id */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Members's roleId */
|
|
7
|
+
roleId: string;
|
|
8
|
+
duration: Date;
|
|
9
|
+
status: "on" | "off";
|
|
10
|
+
/** Members's voiceChannelId */
|
|
11
|
+
voiceChannelId: string;
|
|
12
|
+
/** Vip's type */
|
|
13
|
+
type: "both" | "role" | "channel";
|
|
14
|
+
/** Member's Guild Id */
|
|
15
|
+
guild_id: string;
|
|
16
|
+
/** User's daily */
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
/** Updated Date */
|
|
19
|
+
updatedAt: Date;
|
|
20
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -34,4 +34,6 @@ __exportStar(require("./api/APIGuildUser"), exports);
|
|
|
34
34
|
__exportStar(require("./api/APIMessage"), exports);
|
|
35
35
|
__exportStar(require("./api/APIPlayer"), exports);
|
|
36
36
|
__exportStar(require("./api/APIProduct"), exports);
|
|
37
|
+
__exportStar(require("./api/APIVipMember"), exports);
|
|
38
|
+
__exportStar(require("./api/APIGiveaway"), exports);
|
|
37
39
|
__exportStar(require("./api/index"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRandomNumber(min: number, max: number): number;
|