lunibee 0.1.7 → 0.1.8
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/LICENSE +21 -21
- package/README.md +223 -223
- package/dist/builders/commands.d.ts +6 -4
- package/dist/builders/components.d.ts +18 -0
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/index.js +49 -13
- package/dist/builders/index.js.map +9 -8
- package/dist/collection/index.js +2 -1
- package/dist/collection/index.js.map +4 -4
- package/dist/core/events.d.ts +86 -2
- package/dist/core/index.d.ts +10 -87
- package/dist/core/index.js +1752 -725
- package/dist/core/index.js.map +44 -24
- package/dist/formatters/index.js.map +1 -1
- package/dist/handlers/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2103 -800
- package/dist/index.js.map +63 -43
- package/dist/managers/guild-resources.d.ts +109 -0
- package/dist/managers/guild.d.ts +5 -0
- package/dist/managers/index.d.ts +7 -1
- package/dist/managers/index.js +330 -12
- package/dist/managers/index.js.map +25 -21
- package/dist/rest/decoder.d.ts +23 -0
- package/dist/rest/errors.d.ts +20 -0
- package/dist/rest/index.d.ts +21 -17
- package/dist/rest/index.js +479 -263
- package/dist/rest/index.js.map +14 -8
- package/dist/rest/limiter.d.ts +42 -0
- package/dist/rest/redis.d.ts +18 -1
- package/dist/rest/route.d.ts +31 -0
- package/dist/rest/routes.d.ts +2 -0
- package/dist/rest/scheduler.d.ts +42 -0
- package/dist/rest/store.d.ts +29 -0
- package/dist/rest/transport.d.ts +40 -0
- package/dist/sharding/bus.d.ts +31 -0
- package/dist/sharding/cluster.d.ts +10 -0
- package/dist/sharding/index.d.ts +10 -2
- package/dist/sharding/index.js +1011 -394
- package/dist/sharding/index.js.map +18 -8
- package/dist/structures/base.d.ts +8 -0
- package/dist/structures/channels.d.ts +56 -0
- package/dist/structures/index.d.ts +1 -0
- package/dist/structures/index.js +211 -271
- package/dist/structures/index.js.map +17 -14
- package/dist/structures/interactions.d.ts +12 -52
- package/dist/structures/options.d.ts +55 -0
- package/dist/structures/resources.d.ts +3 -3
- package/dist/types/gateway-events.d.ts +132 -0
- package/dist/types/gateway.d.ts +181 -0
- package/dist/types/index.d.ts +2 -263
- package/dist/types/index.js +44 -2
- package/dist/types/index.js.map +5 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/voice/index.d.ts +29 -1
- package/dist/voice/index.js +59 -7
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/close-codes.d.ts +23 -0
- package/dist/ws/decoder.d.ts +58 -0
- package/dist/ws/heartbeat.d.ts +87 -0
- package/dist/ws/index.d.ts +18 -65
- package/dist/ws/index.js +903 -385
- package/dist/ws/index.js.map +15 -5
- package/dist/ws/opcodes.d.ts +14 -0
- package/dist/ws/protocol.d.ts +110 -0
- package/dist/ws/reconnect.d.ts +108 -0
- package/dist/ws/send-budget.d.ts +17 -0
- package/dist/ws/session.d.ts +100 -0
- package/dist/ws/state.d.ts +27 -0
- package/dist/ws/transport.d.ts +80 -0
- package/package.json +21 -20
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Manager } from "./base.js";
|
|
2
|
+
import { type REST } from "@lunibee/rest";
|
|
3
|
+
import type { APIGuildScheduledEvent, APIStageInstance, UserData } from "@lunibee/types";
|
|
4
|
+
/** Raw Discord ban object. */
|
|
5
|
+
export interface APIBan {
|
|
6
|
+
user: UserData;
|
|
7
|
+
reason: string | null;
|
|
8
|
+
}
|
|
9
|
+
/** Options for {@link GuildBanManager.create}. */
|
|
10
|
+
export interface GuildBanCreateOptions {
|
|
11
|
+
/** Seconds of message history to delete (0-604800). */
|
|
12
|
+
deleteMessageSeconds?: number;
|
|
13
|
+
/** Audit-log reason. */
|
|
14
|
+
reason?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Manages a guild's bans, cached by user ID. Discord.js-familiar. */
|
|
17
|
+
export declare class GuildBanManager extends Manager<string, APIBan> {
|
|
18
|
+
#private;
|
|
19
|
+
readonly guildId: string;
|
|
20
|
+
constructor(rest: REST, guildId: string);
|
|
21
|
+
/** Fetches one ban. */
|
|
22
|
+
fetch(userId: string): Promise<APIBan>;
|
|
23
|
+
/** Fetches a page of bans (`limit` 1-1000, `before`/`after` user-ID cursors). */
|
|
24
|
+
fetchAll(options?: {
|
|
25
|
+
limit?: number;
|
|
26
|
+
before?: string;
|
|
27
|
+
after?: string;
|
|
28
|
+
}): Promise<APIBan[]>;
|
|
29
|
+
/** Bans a user. */
|
|
30
|
+
create(userId: string, options?: GuildBanCreateOptions): Promise<void>;
|
|
31
|
+
/** Lifts a ban. */
|
|
32
|
+
remove(userId: string, reason?: string): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** Fields accepted when creating or editing a scheduled event. */
|
|
35
|
+
export type GuildScheduledEventOptions = Partial<Omit<APIGuildScheduledEvent, "id" | "guild_id" | "creator" | "user_count">> & Record<string, unknown>;
|
|
36
|
+
/** Manages a guild's scheduled events, cached by event ID. Discord.js-familiar. */
|
|
37
|
+
export declare class GuildScheduledEventManager extends Manager<string, APIGuildScheduledEvent> {
|
|
38
|
+
#private;
|
|
39
|
+
readonly guildId: string;
|
|
40
|
+
constructor(rest: REST, guildId: string);
|
|
41
|
+
/** Fetches one event. */
|
|
42
|
+
fetch(eventId: string, options?: {
|
|
43
|
+
withUserCount?: boolean;
|
|
44
|
+
}): Promise<APIGuildScheduledEvent>;
|
|
45
|
+
/** Fetches every event in the guild. */
|
|
46
|
+
fetchAll(options?: {
|
|
47
|
+
withUserCount?: boolean;
|
|
48
|
+
}): Promise<APIGuildScheduledEvent[]>;
|
|
49
|
+
/** Creates an event. */
|
|
50
|
+
create(options: GuildScheduledEventOptions, reason?: string): Promise<APIGuildScheduledEvent>;
|
|
51
|
+
/** Edits an event. */
|
|
52
|
+
edit(eventId: string, options: GuildScheduledEventOptions, reason?: string): Promise<APIGuildScheduledEvent>;
|
|
53
|
+
/** Deletes an event. */
|
|
54
|
+
remove(eventId: string): Promise<void>;
|
|
55
|
+
/** Fetches users subscribed to an event (`limit` 1-100). */
|
|
56
|
+
fetchSubscribers(eventId: string, options?: {
|
|
57
|
+
limit?: number;
|
|
58
|
+
withMember?: boolean;
|
|
59
|
+
before?: string;
|
|
60
|
+
after?: string;
|
|
61
|
+
}): Promise<{
|
|
62
|
+
guild_scheduled_event_id: string;
|
|
63
|
+
user: UserData;
|
|
64
|
+
}[]>;
|
|
65
|
+
}
|
|
66
|
+
/** Options for creating a stage instance. */
|
|
67
|
+
export interface StageInstanceCreateOptions {
|
|
68
|
+
topic: string;
|
|
69
|
+
privacyLevel?: number;
|
|
70
|
+
sendStartNotification?: boolean;
|
|
71
|
+
guildScheduledEventId?: string;
|
|
72
|
+
}
|
|
73
|
+
/** Manages stage instances, cached by stage channel ID. Discord.js-familiar. */
|
|
74
|
+
export declare class StageInstanceManager extends Manager<string, APIStageInstance> {
|
|
75
|
+
#private;
|
|
76
|
+
constructor(rest: REST);
|
|
77
|
+
/** Starts a stage instance in a stage channel. */
|
|
78
|
+
create(channelId: string, options: StageInstanceCreateOptions, reason?: string): Promise<APIStageInstance>;
|
|
79
|
+
/** Fetches the stage instance of a stage channel. */
|
|
80
|
+
fetch(channelId: string): Promise<APIStageInstance>;
|
|
81
|
+
/** Edits a stage instance's topic or privacy level. */
|
|
82
|
+
edit(channelId: string, options: {
|
|
83
|
+
topic?: string;
|
|
84
|
+
privacyLevel?: number;
|
|
85
|
+
}, reason?: string): Promise<APIStageInstance>;
|
|
86
|
+
/** Ends a stage instance. */
|
|
87
|
+
remove(channelId: string, reason?: string): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
/** Overwrite target type: 0 = role, 1 = member. */
|
|
90
|
+
export type PermissionOverwriteTargetType = 0 | 1;
|
|
91
|
+
/** Permission values accepted by {@link PermissionOverwriteManager.edit}. */
|
|
92
|
+
export interface PermissionOverwriteOptions {
|
|
93
|
+
/** Target type: 0 = role, 1 = member. */
|
|
94
|
+
type: PermissionOverwriteTargetType;
|
|
95
|
+
/** Allowed permission bits. */
|
|
96
|
+
allow?: bigint | number | string;
|
|
97
|
+
/** Denied permission bits. */
|
|
98
|
+
deny?: bigint | number | string;
|
|
99
|
+
}
|
|
100
|
+
/** Manages a channel's permission overwrites. Discord.js-familiar. */
|
|
101
|
+
export declare class PermissionOverwriteManager {
|
|
102
|
+
#private;
|
|
103
|
+
readonly channelId: string;
|
|
104
|
+
constructor(rest: REST, channelId: string);
|
|
105
|
+
/** Creates or replaces the overwrite for a role or member. */
|
|
106
|
+
edit(overwriteId: string, options: PermissionOverwriteOptions, reason?: string): Promise<void>;
|
|
107
|
+
/** Deletes the overwrite for a role or member. */
|
|
108
|
+
remove(overwriteId: string, reason?: string): Promise<void>;
|
|
109
|
+
}
|
package/dist/managers/guild.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ResourceManager } from "./base.js";
|
|
2
|
+
import { GuildBanManager, GuildScheduledEventManager } from "./guild-resources.js";
|
|
2
3
|
import { Guild, AutoModerationRule } from "@lunibee/structures";
|
|
3
4
|
import { type REST } from "@lunibee/rest";
|
|
4
5
|
import { type APIChannel, type APIGuildPreview, type APIInvite, type APIWebhook } from "@lunibee/types";
|
|
@@ -10,6 +11,10 @@ export interface GuildEditOptions extends Record<string, unknown> {
|
|
|
10
11
|
export declare class GuildManager extends ResourceManager<string, Guild> {
|
|
11
12
|
#private;
|
|
12
13
|
constructor(rest: REST);
|
|
14
|
+
/** Ban manager for a guild (one instance per guild). */
|
|
15
|
+
bans(guildId: string): GuildBanManager;
|
|
16
|
+
/** Scheduled-event manager for a guild (one instance per guild). */
|
|
17
|
+
scheduledEvents(guildId: string): GuildScheduledEventManager;
|
|
13
18
|
/** Creates a new guild. (Bot must be in fewer than 10 guilds). */
|
|
14
19
|
create(options: GuildCreateOptions): Promise<Guild>;
|
|
15
20
|
/** Modifies a guild's settings. */
|
package/dist/managers/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Manager } from "./base.js";
|
|
2
2
|
export { Manager, ResourceManager } from "./base.js";
|
|
3
|
+
/** Discord.js-familiar alias for {@link ResourceManager}. */
|
|
4
|
+
export { ResourceManager as CachedManager } from "./base.js";
|
|
3
5
|
import { REST } from "@lunibee/rest";
|
|
4
6
|
import { Channel, Message, User } from "@lunibee/structures";
|
|
5
7
|
import { MessageManager, type MessageCreateOptions as ManagerMessageCreateOptions } from "./message.js";
|
|
@@ -37,10 +39,13 @@ export interface ChannelCreateOptions extends Record<string, unknown> {
|
|
|
37
39
|
parent_id?: string | null;
|
|
38
40
|
}
|
|
39
41
|
export type ChannelEditOptions = Record<string, unknown>;
|
|
42
|
+
import { PermissionOverwriteManager } from "./guild-resources.js";
|
|
40
43
|
export declare class ChannelManager extends Manager<string, Channel> {
|
|
41
44
|
#private;
|
|
42
45
|
constructor(rest: REST);
|
|
43
46
|
messages(channelId: string): MessageManager;
|
|
47
|
+
/** Permission overwrite manager for a channel. */
|
|
48
|
+
permissionOverwrites(channelId: string): PermissionOverwriteManager;
|
|
44
49
|
threads(channelId: string): ThreadManager;
|
|
45
50
|
fetch(channelId: string): Promise<Channel>;
|
|
46
51
|
resolve(channelId: string): Promise<Channel>;
|
|
@@ -104,4 +109,5 @@ export { ThreadManager } from "./thread.js";
|
|
|
104
109
|
export { RoleManager, type RoleCreateOptions, type RoleEditOptions, } from "./role.js";
|
|
105
110
|
export { GuildMemberManager, type MemberEditOptions, type BanOptions, } from "./member.js";
|
|
106
111
|
export { ApplicationCommandManager } from "./application.js";
|
|
107
|
-
export {
|
|
112
|
+
export { GuildBanManager, GuildScheduledEventManager, StageInstanceManager, PermissionOverwriteManager, type APIBan, type GuildBanCreateOptions, type GuildScheduledEventOptions, type StageInstanceCreateOptions, type PermissionOverwriteOptions, type PermissionOverwriteTargetType, } from "./guild-resources.js";
|
|
113
|
+
export { EmojiManager, type EmojiCreateOptions, type EmojiEditOptions, } from "./emoji.js";
|
package/dist/managers/index.js
CHANGED
|
@@ -285,7 +285,7 @@ class ResourceManager extends Manager {
|
|
|
285
285
|
// packages/rest/package.json
|
|
286
286
|
var package_default = {
|
|
287
287
|
name: "@lunibee/rest",
|
|
288
|
-
version: "0.1.
|
|
288
|
+
version: "0.1.8",
|
|
289
289
|
type: "module",
|
|
290
290
|
module: "./src/index.ts",
|
|
291
291
|
types: "./src/index.ts",
|
|
@@ -335,6 +335,8 @@ var Routes = {
|
|
|
335
335
|
threadMembers: (threadId) => `/channels/${snowflake(threadId, "Thread ID")}/thread-members`,
|
|
336
336
|
guildScheduledEvents: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/scheduled-events`,
|
|
337
337
|
guildScheduledEvent: (guildId, eventId) => `/guilds/${snowflake(guildId, "Guild ID")}/scheduled-events/${snowflake(eventId, "Event ID")}`,
|
|
338
|
+
guildScheduledEventUsers: (guildId, eventId) => `/guilds/${snowflake(guildId, "Guild ID")}/scheduled-events/${snowflake(eventId, "Event ID")}/users`,
|
|
339
|
+
channelPermission: (channelId, overwriteId) => `/channels/${snowflake(channelId, "Channel ID")}/permissions/${snowflake(overwriteId, "Overwrite ID")}`,
|
|
338
340
|
guildAutoModerationRules: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/auto-moderation/rules`,
|
|
339
341
|
guildAutoModerationRule: (guildId, ruleId) => `/guilds/${snowflake(guildId, "Guild ID")}/auto-moderation/rules/${snowflake(ruleId, "Rule ID")}`,
|
|
340
342
|
voiceRegions: () => "/voice/regions",
|
|
@@ -357,6 +359,7 @@ function snowflake(value, field) {
|
|
|
357
359
|
throw new TypeError(`${field} must be a valid Discord snowflake.`);
|
|
358
360
|
return value;
|
|
359
361
|
}
|
|
362
|
+
|
|
360
363
|
// packages/rest/src/index.ts
|
|
361
364
|
var LIBRARY_VERSION = package_default.version;
|
|
362
365
|
var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
|
|
@@ -490,6 +493,18 @@ class Channel extends BaseStructure {
|
|
|
490
493
|
update(options) {
|
|
491
494
|
return this.edit(options);
|
|
492
495
|
}
|
|
496
|
+
isThread() {
|
|
497
|
+
return this.type === 10 || this.type === 11 || this.type === 12;
|
|
498
|
+
}
|
|
499
|
+
isTextBased() {
|
|
500
|
+
return [0, 1, 2, 3, 5, 10, 11, 12, 13].includes(this.type);
|
|
501
|
+
}
|
|
502
|
+
isVoiceBased() {
|
|
503
|
+
return this.type === 2 || this.type === 13;
|
|
504
|
+
}
|
|
505
|
+
isDMBased() {
|
|
506
|
+
return this.type === 1 || this.type === 3;
|
|
507
|
+
}
|
|
493
508
|
toString() {
|
|
494
509
|
return `<#${this.id}>`;
|
|
495
510
|
}
|
|
@@ -1016,7 +1031,7 @@ class PermissionsBitField extends PermissionSet {
|
|
|
1016
1031
|
super(value);
|
|
1017
1032
|
}
|
|
1018
1033
|
}
|
|
1019
|
-
// packages/types/src/
|
|
1034
|
+
// packages/types/src/gateway.ts
|
|
1020
1035
|
var GatewayIntentBits = {
|
|
1021
1036
|
Guilds: 1 << 0,
|
|
1022
1037
|
GuildMembers: 1 << 1,
|
|
@@ -1068,6 +1083,37 @@ var IntentBits = {
|
|
|
1068
1083
|
guildMessagePolls: 1 << 24,
|
|
1069
1084
|
directMessagePolls: 1 << 25
|
|
1070
1085
|
};
|
|
1086
|
+
// packages/ws/src/close-codes.ts
|
|
1087
|
+
var GatewayCloseCodes = {
|
|
1088
|
+
UnknownError: 4000,
|
|
1089
|
+
UnknownOpcode: 4001,
|
|
1090
|
+
DecodeError: 4002,
|
|
1091
|
+
NotAuthenticated: 4003,
|
|
1092
|
+
AuthenticationFailed: 4004,
|
|
1093
|
+
AlreadyAuthenticated: 4005,
|
|
1094
|
+
InvalidSeq: 4007,
|
|
1095
|
+
RateLimited: 4008,
|
|
1096
|
+
SessionTimedOut: 4009,
|
|
1097
|
+
InvalidShard: 4010,
|
|
1098
|
+
ShardingRequired: 4011,
|
|
1099
|
+
InvalidAPIVersion: 4012,
|
|
1100
|
+
InvalidIntents: 4013,
|
|
1101
|
+
DisallowedIntents: 4014
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
// packages/ws/src/reconnect.ts
|
|
1105
|
+
var FATAL_CLOSE_CODES = [
|
|
1106
|
+
GatewayCloseCodes.AuthenticationFailed,
|
|
1107
|
+
GatewayCloseCodes.InvalidShard,
|
|
1108
|
+
GatewayCloseCodes.ShardingRequired,
|
|
1109
|
+
GatewayCloseCodes.InvalidAPIVersion,
|
|
1110
|
+
GatewayCloseCodes.InvalidIntents,
|
|
1111
|
+
GatewayCloseCodes.DisallowedIntents
|
|
1112
|
+
];
|
|
1113
|
+
var IDENTIFY_CLOSE_CODES = [
|
|
1114
|
+
GatewayCloseCodes.InvalidSeq,
|
|
1115
|
+
GatewayCloseCodes.SessionTimedOut
|
|
1116
|
+
];
|
|
1071
1117
|
// packages/structures/src/resources.ts
|
|
1072
1118
|
function toDateOrNull(value) {
|
|
1073
1119
|
if (!value)
|
|
@@ -1165,6 +1211,15 @@ class Role extends BaseStructure {
|
|
|
1165
1211
|
return `<@&${this.id}>`;
|
|
1166
1212
|
}
|
|
1167
1213
|
}
|
|
1214
|
+
|
|
1215
|
+
class TextChannel extends Channel {
|
|
1216
|
+
constructor(data, context) {
|
|
1217
|
+
super(data, context);
|
|
1218
|
+
}
|
|
1219
|
+
toString() {
|
|
1220
|
+
return `<#${this.id}>`;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1168
1223
|
class Emoji extends BaseStructure {
|
|
1169
1224
|
name;
|
|
1170
1225
|
roleIds;
|
|
@@ -1174,7 +1229,9 @@ class Emoji extends BaseStructure {
|
|
|
1174
1229
|
animated;
|
|
1175
1230
|
available;
|
|
1176
1231
|
constructor(data) {
|
|
1177
|
-
super(data.id ?? "
|
|
1232
|
+
super(data.id ?? "0");
|
|
1233
|
+
if (data.id === null)
|
|
1234
|
+
this.id = "unicode";
|
|
1178
1235
|
this.name = data.name;
|
|
1179
1236
|
this.roleIds = data.roles ?? [];
|
|
1180
1237
|
this.user = data.user ? new User(data.user) : null;
|
|
@@ -1237,6 +1294,106 @@ class AutoModerationRule extends BaseStructure {
|
|
|
1237
1294
|
};
|
|
1238
1295
|
}
|
|
1239
1296
|
}
|
|
1297
|
+
// packages/structures/src/channels.ts
|
|
1298
|
+
class NewsChannel extends TextChannel {
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
class DMChannel extends Channel {
|
|
1302
|
+
recipients;
|
|
1303
|
+
ownerId;
|
|
1304
|
+
constructor(data, context) {
|
|
1305
|
+
super(data, context);
|
|
1306
|
+
this.recipients = (data.recipients ?? []).map((u) => new User(u));
|
|
1307
|
+
this.ownerId = data.owner_id ?? null;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
class VoiceChannel extends Channel {
|
|
1312
|
+
bitrate;
|
|
1313
|
+
userLimit;
|
|
1314
|
+
rtcRegion;
|
|
1315
|
+
videoQualityMode;
|
|
1316
|
+
constructor(data, context) {
|
|
1317
|
+
super(data, context);
|
|
1318
|
+
this.bitrate = data.bitrate ?? 64000;
|
|
1319
|
+
this.userLimit = data.user_limit ?? 0;
|
|
1320
|
+
this.rtcRegion = data.rtc_region ?? null;
|
|
1321
|
+
this.videoQualityMode = data.video_quality_mode ?? 1;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
class StageChannel extends VoiceChannel {
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
class CategoryChannel extends Channel {
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
class ThreadChannel extends Channel {
|
|
1332
|
+
ownerId;
|
|
1333
|
+
messageCount;
|
|
1334
|
+
memberCount;
|
|
1335
|
+
metadata;
|
|
1336
|
+
constructor(data, context) {
|
|
1337
|
+
super(data, context);
|
|
1338
|
+
this.ownerId = data.owner_id ?? null;
|
|
1339
|
+
this.messageCount = data.message_count ?? 0;
|
|
1340
|
+
this.memberCount = data.member_count ?? 0;
|
|
1341
|
+
this.metadata = data.thread_metadata ?? null;
|
|
1342
|
+
}
|
|
1343
|
+
get archived() {
|
|
1344
|
+
return this.metadata?.archived ?? false;
|
|
1345
|
+
}
|
|
1346
|
+
get locked() {
|
|
1347
|
+
return this.metadata?.locked ?? false;
|
|
1348
|
+
}
|
|
1349
|
+
get autoArchiveDuration() {
|
|
1350
|
+
return this.metadata?.auto_archive_duration ?? null;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
class ForumChannel extends Channel {
|
|
1355
|
+
availableTags;
|
|
1356
|
+
defaultReactionEmoji;
|
|
1357
|
+
defaultThreadRateLimitPerUser;
|
|
1358
|
+
defaultAutoArchiveDuration;
|
|
1359
|
+
constructor(data, context) {
|
|
1360
|
+
super(data, context);
|
|
1361
|
+
this.availableTags = data.available_tags ?? [];
|
|
1362
|
+
this.defaultReactionEmoji = data.default_reaction_emoji ?? null;
|
|
1363
|
+
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? 0;
|
|
1364
|
+
this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
class MediaChannel extends ForumChannel {
|
|
1369
|
+
}
|
|
1370
|
+
function createChannel(data, context) {
|
|
1371
|
+
switch (data.type) {
|
|
1372
|
+
case 0:
|
|
1373
|
+
return new TextChannel(data, context);
|
|
1374
|
+
case 1:
|
|
1375
|
+
case 3:
|
|
1376
|
+
return new DMChannel(data, context);
|
|
1377
|
+
case 2:
|
|
1378
|
+
return new VoiceChannel(data, context);
|
|
1379
|
+
case 4:
|
|
1380
|
+
return new CategoryChannel(data, context);
|
|
1381
|
+
case 5:
|
|
1382
|
+
return new NewsChannel(data, context);
|
|
1383
|
+
case 10:
|
|
1384
|
+
case 11:
|
|
1385
|
+
case 12:
|
|
1386
|
+
return new ThreadChannel(data, context);
|
|
1387
|
+
case 13:
|
|
1388
|
+
return new StageChannel(data, context);
|
|
1389
|
+
case 15:
|
|
1390
|
+
return new ForumChannel(data, context);
|
|
1391
|
+
case 16:
|
|
1392
|
+
return new MediaChannel(data, context);
|
|
1393
|
+
default:
|
|
1394
|
+
return new Channel(data, context);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1240
1397
|
// packages/structures/src/index.ts
|
|
1241
1398
|
var NON_SYSTEM_MESSAGE_TYPES = new Set([0, 19, 20, 23]);
|
|
1242
1399
|
|
|
@@ -1452,7 +1609,7 @@ class ThreadManager {
|
|
|
1452
1609
|
auto_archive_duration: options.autoArchiveDuration,
|
|
1453
1610
|
rate_limit_per_user: options.rateLimitPerUser
|
|
1454
1611
|
});
|
|
1455
|
-
return
|
|
1612
|
+
return createChannel(data, this.#context);
|
|
1456
1613
|
}
|
|
1457
1614
|
}
|
|
1458
1615
|
|
|
@@ -1480,18 +1637,173 @@ class UserManager extends ResourceManager {
|
|
|
1480
1637
|
});
|
|
1481
1638
|
}
|
|
1482
1639
|
}
|
|
1483
|
-
// packages/managers/src/guild.ts
|
|
1640
|
+
// packages/managers/src/guild-resources.ts
|
|
1484
1641
|
function withQuery(path, params) {
|
|
1642
|
+
const query = new URLSearchParams;
|
|
1643
|
+
for (const [key, value] of Object.entries(params))
|
|
1644
|
+
if (value !== undefined)
|
|
1645
|
+
query.set(key, String(value));
|
|
1646
|
+
const suffix = query.toString();
|
|
1647
|
+
return suffix ? `${path}?${suffix}` : path;
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
class GuildBanManager extends Manager {
|
|
1651
|
+
#rest;
|
|
1652
|
+
guildId;
|
|
1653
|
+
constructor(rest, guildId) {
|
|
1654
|
+
super();
|
|
1655
|
+
this.#rest = rest;
|
|
1656
|
+
this.guildId = guildId;
|
|
1657
|
+
}
|
|
1658
|
+
async fetch(userId) {
|
|
1659
|
+
const ban = await this.#rest.get(Routes.guildBan(this.guildId, userId));
|
|
1660
|
+
this.set(ban.user.id, ban);
|
|
1661
|
+
return ban;
|
|
1662
|
+
}
|
|
1663
|
+
async fetchAll(options = {}) {
|
|
1664
|
+
const limit = options.limit === undefined ? undefined : Math.min(1000, Math.max(1, options.limit));
|
|
1665
|
+
const bans = await this.#rest.get(withQuery(Routes.guildBans(this.guildId), {
|
|
1666
|
+
limit,
|
|
1667
|
+
before: options.before,
|
|
1668
|
+
after: options.after
|
|
1669
|
+
}));
|
|
1670
|
+
for (const ban of bans)
|
|
1671
|
+
this.set(ban.user.id, ban);
|
|
1672
|
+
return bans;
|
|
1673
|
+
}
|
|
1674
|
+
async create(userId, options = {}) {
|
|
1675
|
+
await this.#rest.put(Routes.guildBan(this.guildId, userId), { delete_message_seconds: options.deleteMessageSeconds }, { reason: options.reason });
|
|
1676
|
+
}
|
|
1677
|
+
async remove(userId, reason) {
|
|
1678
|
+
await this.#rest.delete(Routes.guildBan(this.guildId, userId), {
|
|
1679
|
+
reason
|
|
1680
|
+
});
|
|
1681
|
+
this.delete(userId);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
class GuildScheduledEventManager extends Manager {
|
|
1686
|
+
#rest;
|
|
1687
|
+
guildId;
|
|
1688
|
+
constructor(rest, guildId) {
|
|
1689
|
+
super();
|
|
1690
|
+
this.#rest = rest;
|
|
1691
|
+
this.guildId = guildId;
|
|
1692
|
+
}
|
|
1693
|
+
#store(event) {
|
|
1694
|
+
this.set(event.id, event);
|
|
1695
|
+
return event;
|
|
1696
|
+
}
|
|
1697
|
+
async fetch(eventId, options = {}) {
|
|
1698
|
+
return this.#store(await this.#rest.get(withQuery(Routes.guildScheduledEvent(this.guildId, eventId), {
|
|
1699
|
+
with_user_count: options.withUserCount
|
|
1700
|
+
})));
|
|
1701
|
+
}
|
|
1702
|
+
async fetchAll(options = {}) {
|
|
1703
|
+
const events = await this.#rest.get(withQuery(Routes.guildScheduledEvents(this.guildId), {
|
|
1704
|
+
with_user_count: options.withUserCount
|
|
1705
|
+
}));
|
|
1706
|
+
return events.map((event) => this.#store(event));
|
|
1707
|
+
}
|
|
1708
|
+
async create(options, reason) {
|
|
1709
|
+
return this.#store(await this.#rest.post(Routes.guildScheduledEvents(this.guildId), options, { reason }));
|
|
1710
|
+
}
|
|
1711
|
+
async edit(eventId, options, reason) {
|
|
1712
|
+
return this.#store(await this.#rest.patch(Routes.guildScheduledEvent(this.guildId, eventId), options, { reason }));
|
|
1713
|
+
}
|
|
1714
|
+
async remove(eventId) {
|
|
1715
|
+
await this.#rest.delete(Routes.guildScheduledEvent(this.guildId, eventId));
|
|
1716
|
+
this.delete(eventId);
|
|
1717
|
+
}
|
|
1718
|
+
async fetchSubscribers(eventId, options = {}) {
|
|
1719
|
+
const limit = options.limit === undefined ? undefined : Math.min(100, Math.max(1, options.limit));
|
|
1720
|
+
return this.#rest.get(withQuery(Routes.guildScheduledEventUsers(this.guildId, eventId), {
|
|
1721
|
+
limit,
|
|
1722
|
+
with_member: options.withMember,
|
|
1723
|
+
before: options.before,
|
|
1724
|
+
after: options.after
|
|
1725
|
+
}));
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
class StageInstanceManager extends Manager {
|
|
1730
|
+
#rest;
|
|
1731
|
+
constructor(rest) {
|
|
1732
|
+
super();
|
|
1733
|
+
this.#rest = rest;
|
|
1734
|
+
}
|
|
1735
|
+
#store(stage) {
|
|
1736
|
+
this.set(stage.channel_id, stage);
|
|
1737
|
+
return stage;
|
|
1738
|
+
}
|
|
1739
|
+
async create(channelId, options, reason) {
|
|
1740
|
+
return this.#store(await this.#rest.post(Routes.stageInstances(), {
|
|
1741
|
+
channel_id: channelId,
|
|
1742
|
+
topic: options.topic,
|
|
1743
|
+
privacy_level: options.privacyLevel,
|
|
1744
|
+
send_start_notification: options.sendStartNotification,
|
|
1745
|
+
guild_scheduled_event_id: options.guildScheduledEventId
|
|
1746
|
+
}, { reason }));
|
|
1747
|
+
}
|
|
1748
|
+
async fetch(channelId) {
|
|
1749
|
+
return this.#store(await this.#rest.get(Routes.stageInstanceByChannel(channelId)));
|
|
1750
|
+
}
|
|
1751
|
+
async edit(channelId, options, reason) {
|
|
1752
|
+
return this.#store(await this.#rest.patch(Routes.stageInstanceByChannel(channelId), { topic: options.topic, privacy_level: options.privacyLevel }, { reason }));
|
|
1753
|
+
}
|
|
1754
|
+
async remove(channelId, reason) {
|
|
1755
|
+
await this.#rest.delete(Routes.stageInstanceByChannel(channelId), {
|
|
1756
|
+
reason
|
|
1757
|
+
});
|
|
1758
|
+
this.delete(channelId);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
class PermissionOverwriteManager {
|
|
1763
|
+
#rest;
|
|
1764
|
+
channelId;
|
|
1765
|
+
constructor(rest, channelId) {
|
|
1766
|
+
this.#rest = rest;
|
|
1767
|
+
this.channelId = channelId;
|
|
1768
|
+
}
|
|
1769
|
+
async edit(overwriteId, options, reason) {
|
|
1770
|
+
await this.#rest.put(Routes.channelPermission(this.channelId, overwriteId), {
|
|
1771
|
+
type: options.type,
|
|
1772
|
+
allow: BigInt(options.allow ?? 0).toString(),
|
|
1773
|
+
deny: BigInt(options.deny ?? 0).toString()
|
|
1774
|
+
}, { reason });
|
|
1775
|
+
}
|
|
1776
|
+
async remove(overwriteId, reason) {
|
|
1777
|
+
await this.#rest.delete(Routes.channelPermission(this.channelId, overwriteId), { reason });
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
// packages/managers/src/guild.ts
|
|
1782
|
+
function withQuery2(path, params) {
|
|
1485
1783
|
const suffix = params.toString();
|
|
1486
1784
|
return suffix ? `${path}?${suffix}` : path;
|
|
1487
1785
|
}
|
|
1488
1786
|
|
|
1489
1787
|
class GuildManager extends ResourceManager {
|
|
1490
1788
|
#rest;
|
|
1789
|
+
#bans = new Map;
|
|
1790
|
+
#scheduledEvents = new Map;
|
|
1491
1791
|
constructor(rest) {
|
|
1492
1792
|
super(async (id) => new Guild(await rest.get(Routes.guild(id))), (guild) => guild.id);
|
|
1493
1793
|
this.#rest = rest;
|
|
1494
1794
|
}
|
|
1795
|
+
bans(guildId) {
|
|
1796
|
+
let manager = this.#bans.get(guildId);
|
|
1797
|
+
if (!manager)
|
|
1798
|
+
this.#bans.set(guildId, manager = new GuildBanManager(this.#rest, guildId));
|
|
1799
|
+
return manager;
|
|
1800
|
+
}
|
|
1801
|
+
scheduledEvents(guildId) {
|
|
1802
|
+
let manager = this.#scheduledEvents.get(guildId);
|
|
1803
|
+
if (!manager)
|
|
1804
|
+
this.#scheduledEvents.set(guildId, manager = new GuildScheduledEventManager(this.#rest, guildId));
|
|
1805
|
+
return manager;
|
|
1806
|
+
}
|
|
1495
1807
|
async create(options) {
|
|
1496
1808
|
const data = await this.#rest.post("/guilds", options);
|
|
1497
1809
|
return this.upsert(new Guild(data));
|
|
@@ -1527,7 +1839,7 @@ class GuildManager extends ResourceManager {
|
|
|
1527
1839
|
params.set("after", options.after);
|
|
1528
1840
|
if (options.limit !== undefined)
|
|
1529
1841
|
params.set("limit", String(Math.min(100, Math.max(1, options.limit))));
|
|
1530
|
-
return this.#rest.get(
|
|
1842
|
+
return this.#rest.get(withQuery2(Routes.guildAuditLog(guildId), params));
|
|
1531
1843
|
}
|
|
1532
1844
|
async fetchMembers(guildId, options = {}) {
|
|
1533
1845
|
const params = new URLSearchParams;
|
|
@@ -1535,7 +1847,7 @@ class GuildManager extends ResourceManager {
|
|
|
1535
1847
|
params.set("limit", String(Math.min(1000, Math.max(1, options.limit))));
|
|
1536
1848
|
if (options.after)
|
|
1537
1849
|
params.set("after", options.after);
|
|
1538
|
-
return this.#rest.get(
|
|
1850
|
+
return this.#rest.get(withQuery2(Routes.guildMembers(guildId), params));
|
|
1539
1851
|
}
|
|
1540
1852
|
async fetchAutoModerationRules(guildId) {
|
|
1541
1853
|
const rules = await this.#rest.get(Routes.guildAutoModerationRules(guildId));
|
|
@@ -1666,9 +1978,7 @@ class GuildMemberManager extends ResourceManager {
|
|
|
1666
1978
|
this.delete(userId);
|
|
1667
1979
|
}
|
|
1668
1980
|
async ban(userId, options = {}) {
|
|
1669
|
-
await this.#rest.put(Routes.guildBan(this.guildId, userId), {
|
|
1670
|
-
delete_message_seconds: options.deleteMessageSeconds
|
|
1671
|
-
});
|
|
1981
|
+
await this.#rest.put(Routes.guildBan(this.guildId, userId), { delete_message_seconds: options.deleteMessageSeconds }, { reason: options.reason });
|
|
1672
1982
|
this.delete(userId);
|
|
1673
1983
|
}
|
|
1674
1984
|
async unban(userId) {
|
|
@@ -1800,6 +2110,9 @@ class ChannelManager extends Manager {
|
|
|
1800
2110
|
}
|
|
1801
2111
|
return manager;
|
|
1802
2112
|
}
|
|
2113
|
+
permissionOverwrites(channelId) {
|
|
2114
|
+
return new PermissionOverwriteManager(this.#rest, channelId);
|
|
2115
|
+
}
|
|
1803
2116
|
threads(channelId) {
|
|
1804
2117
|
return new ThreadManager(this.#rest, this.#context, channelId);
|
|
1805
2118
|
}
|
|
@@ -1811,7 +2124,7 @@ class ChannelManager extends Manager {
|
|
|
1811
2124
|
}
|
|
1812
2125
|
upsert(data) {
|
|
1813
2126
|
const existing = this.get(data.id);
|
|
1814
|
-
const channel =
|
|
2127
|
+
const channel = createChannel(data, this.#context);
|
|
1815
2128
|
if (existing) {
|
|
1816
2129
|
Object.assign(existing, channel);
|
|
1817
2130
|
return existing;
|
|
@@ -1949,16 +2262,21 @@ function isMessageQuery(value) {
|
|
|
1949
2262
|
export {
|
|
1950
2263
|
ApplicationCommandManager,
|
|
1951
2264
|
AuditLogEvent,
|
|
2265
|
+
ResourceManager as CachedManager,
|
|
1952
2266
|
ChannelManager,
|
|
1953
2267
|
EmojiManager,
|
|
2268
|
+
GuildBanManager,
|
|
1954
2269
|
GuildManager,
|
|
1955
2270
|
GuildMemberManager,
|
|
2271
|
+
GuildScheduledEventManager,
|
|
1956
2272
|
Manager,
|
|
1957
2273
|
MessageManager,
|
|
2274
|
+
PermissionOverwriteManager,
|
|
1958
2275
|
ResourceManager,
|
|
1959
2276
|
RoleManager,
|
|
2277
|
+
StageInstanceManager,
|
|
1960
2278
|
ThreadManager,
|
|
1961
2279
|
UserManager
|
|
1962
2280
|
};
|
|
1963
2281
|
|
|
1964
|
-
//# debugId=
|
|
2282
|
+
//# debugId=E5CAD3E6B2BD672164756E2164756E21
|