lunibee 0.1.0 → 0.1.2
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/README.md +229 -0
- package/dist/builders/attachment.d.ts +20 -0
- package/dist/builders/commands.d.ts +118 -0
- package/dist/builders/components.d.ts +151 -0
- package/dist/builders/embed.d.ts +59 -0
- package/dist/builders/index.d.ts +5 -0
- package/dist/builders/index.js +828 -0
- package/dist/builders/index.js.map +13 -0
- package/dist/collection/cache.d.ts +37 -0
- package/dist/collection/index.d.ts +47 -0
- package/dist/collection/index.js +214 -0
- package/dist/collection/index.js.map +11 -0
- package/dist/core/client-state.d.ts +10 -0
- package/dist/core/collector.d.ts +27 -0
- package/dist/core/events.d.ts +5 -0
- package/dist/core/index.d.ts +111 -0
- package/dist/core/index.js +3188 -0
- package/dist/core/index.js.map +29 -0
- package/dist/core/permissions.d.ts +293 -0
- package/dist/formatters/index.d.ts +10 -0
- package/dist/formatters/index.js +43 -0
- package/dist/formatters/index.js.map +10 -0
- package/dist/handlers/index.d.ts +16 -0
- package/dist/handlers/index.js +37 -0
- package/dist/handlers/index.js.map +10 -0
- package/{src/index.ts → dist/index.d.ts} +2 -29
- package/dist/index.js +4182 -0
- package/dist/index.js.map +41 -0
- package/dist/managers/application.d.ts +28 -0
- package/dist/managers/base.d.ts +28 -0
- package/dist/managers/index.d.ts +96 -0
- package/dist/managers/index.js +947 -0
- package/dist/managers/index.js.map +22 -0
- package/dist/managers/member.d.ts +35 -0
- package/dist/managers/message.d.ts +25 -0
- package/dist/managers/role.d.ts +34 -0
- package/dist/managers/thread.d.ts +14 -0
- package/dist/rest/index.d.ts +49 -0
- package/dist/rest/index.js +344 -0
- package/dist/rest/index.js.map +12 -0
- package/dist/rest/routes.d.ts +44 -0
- package/dist/rest/types.d.ts +26 -0
- package/dist/rest/webhook.d.ts +40 -0
- package/dist/sharding/bus.d.ts +22 -0
- package/dist/sharding/index.d.ts +34 -0
- package/dist/sharding/index.js +732 -0
- package/dist/sharding/index.js.map +13 -0
- package/dist/structures/base.d.ts +75 -0
- package/dist/structures/index.d.ts +39 -0
- package/dist/structures/index.js +571 -0
- package/dist/structures/index.js.map +14 -0
- package/dist/structures/interactions.d.ts +136 -0
- package/dist/structures/permissions.d.ts +73 -0
- package/dist/structures/resources.d.ts +64 -0
- package/dist/types/index.d.ts +535 -0
- package/dist/types/index.js +132 -0
- package/dist/types/index.js.map +10 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +10 -0
- package/dist/voice/index.d.ts +97 -0
- package/dist/voice/index.js +161 -0
- package/dist/voice/index.js.map +10 -0
- package/dist/ws/index.d.ts +76 -0
- package/dist/ws/index.js +582 -0
- package/dist/ws/index.js.map +11 -0
- package/package.json +113 -28
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/** Permission overwrite target types. */
|
|
2
|
+
export declare enum PermissionOverwriteType {
|
|
3
|
+
Role = 0,
|
|
4
|
+
Member = 1
|
|
5
|
+
}
|
|
6
|
+
/** Lunibee idiomatic camelCase permission bitflags. */
|
|
7
|
+
export declare const Permission: {
|
|
8
|
+
readonly createInstantInvite: bigint;
|
|
9
|
+
readonly kickMembers: bigint;
|
|
10
|
+
readonly banMembers: bigint;
|
|
11
|
+
readonly administrator: bigint;
|
|
12
|
+
readonly manageChannels: bigint;
|
|
13
|
+
readonly manageGuild: bigint;
|
|
14
|
+
readonly addReactions: bigint;
|
|
15
|
+
readonly viewAuditLog: bigint;
|
|
16
|
+
readonly prioritySpeaker: bigint;
|
|
17
|
+
readonly stream: bigint;
|
|
18
|
+
readonly viewChannel: bigint;
|
|
19
|
+
readonly sendMessages: bigint;
|
|
20
|
+
readonly sendTTSMessages: bigint;
|
|
21
|
+
readonly manageMessages: bigint;
|
|
22
|
+
readonly embedLinks: bigint;
|
|
23
|
+
readonly attachFiles: bigint;
|
|
24
|
+
readonly readMessageHistory: bigint;
|
|
25
|
+
readonly mentionEveryone: bigint;
|
|
26
|
+
readonly useExternalEmojis: bigint;
|
|
27
|
+
readonly viewGuildInsights: bigint;
|
|
28
|
+
readonly connect: bigint;
|
|
29
|
+
readonly speak: bigint;
|
|
30
|
+
readonly muteMembers: bigint;
|
|
31
|
+
readonly deafenMembers: bigint;
|
|
32
|
+
readonly moveMembers: bigint;
|
|
33
|
+
readonly useVAD: bigint;
|
|
34
|
+
readonly changeNickname: bigint;
|
|
35
|
+
readonly manageNicknames: bigint;
|
|
36
|
+
readonly manageRoles: bigint;
|
|
37
|
+
readonly manageWebhooks: bigint;
|
|
38
|
+
readonly manageGuildExpressions: bigint;
|
|
39
|
+
readonly useApplicationCommands: bigint;
|
|
40
|
+
readonly requestToSpeak: bigint;
|
|
41
|
+
readonly manageEvents: bigint;
|
|
42
|
+
readonly manageThreads: bigint;
|
|
43
|
+
readonly createPublicThreads: bigint;
|
|
44
|
+
readonly createPrivateThreads: bigint;
|
|
45
|
+
readonly useExternalStickers: bigint;
|
|
46
|
+
readonly sendMessagesInThreads: bigint;
|
|
47
|
+
readonly useEmbeddedActivities: bigint;
|
|
48
|
+
readonly moderateMembers: bigint;
|
|
49
|
+
readonly viewCreatorMonetizationAnalytics: bigint;
|
|
50
|
+
readonly useSoundboard: bigint;
|
|
51
|
+
readonly createGuildExpressions: bigint;
|
|
52
|
+
readonly createEvents: bigint;
|
|
53
|
+
readonly useExternalSounds: bigint;
|
|
54
|
+
readonly sendVoiceMessages: bigint;
|
|
55
|
+
readonly sendPolls: bigint;
|
|
56
|
+
readonly useExternalApps: bigint;
|
|
57
|
+
};
|
|
58
|
+
/** Canonical PascalCase permission constants. */
|
|
59
|
+
export declare const Permissions: {
|
|
60
|
+
readonly CreateInstantInvite: bigint;
|
|
61
|
+
readonly KickMembers: bigint;
|
|
62
|
+
readonly BanMembers: bigint;
|
|
63
|
+
readonly Administrator: bigint;
|
|
64
|
+
readonly ManageChannels: bigint;
|
|
65
|
+
readonly ManageGuild: bigint;
|
|
66
|
+
readonly AddReactions: bigint;
|
|
67
|
+
readonly ViewAuditLog: bigint;
|
|
68
|
+
readonly PrioritySpeaker: bigint;
|
|
69
|
+
readonly Stream: bigint;
|
|
70
|
+
readonly ViewChannel: bigint;
|
|
71
|
+
readonly SendMessages: bigint;
|
|
72
|
+
readonly SendTTSMessages: bigint;
|
|
73
|
+
readonly ManageMessages: bigint;
|
|
74
|
+
readonly EmbedLinks: bigint;
|
|
75
|
+
readonly AttachFiles: bigint;
|
|
76
|
+
readonly ReadMessageHistory: bigint;
|
|
77
|
+
readonly MentionEveryone: bigint;
|
|
78
|
+
readonly UseExternalEmojis: bigint;
|
|
79
|
+
readonly ViewGuildInsights: bigint;
|
|
80
|
+
readonly Connect: bigint;
|
|
81
|
+
readonly Speak: bigint;
|
|
82
|
+
readonly MuteMembers: bigint;
|
|
83
|
+
readonly DeafenMembers: bigint;
|
|
84
|
+
readonly MoveMembers: bigint;
|
|
85
|
+
readonly UseVAD: bigint;
|
|
86
|
+
readonly ChangeNickname: bigint;
|
|
87
|
+
readonly ManageNicknames: bigint;
|
|
88
|
+
readonly ManageRoles: bigint;
|
|
89
|
+
readonly ManageWebhooks: bigint;
|
|
90
|
+
readonly ManageGuildExpressions: bigint;
|
|
91
|
+
readonly UseApplicationCommands: bigint;
|
|
92
|
+
readonly RequestToSpeak: bigint;
|
|
93
|
+
readonly ManageEvents: bigint;
|
|
94
|
+
readonly ManageThreads: bigint;
|
|
95
|
+
readonly CreatePublicThreads: bigint;
|
|
96
|
+
readonly CreatePrivateThreads: bigint;
|
|
97
|
+
readonly UseExternalStickers: bigint;
|
|
98
|
+
readonly SendMessagesInThreads: bigint;
|
|
99
|
+
readonly UseEmbeddedActivities: bigint;
|
|
100
|
+
readonly ModerateMembers: bigint;
|
|
101
|
+
readonly ViewCreatorMonetizationAnalytics: bigint;
|
|
102
|
+
readonly UseSoundboard: bigint;
|
|
103
|
+
readonly CreateGuildExpressions: bigint;
|
|
104
|
+
readonly CreateEvents: bigint;
|
|
105
|
+
readonly UseExternalSounds: bigint;
|
|
106
|
+
readonly SendVoiceMessages: bigint;
|
|
107
|
+
readonly SendPolls: bigint;
|
|
108
|
+
readonly UseExternalApps: bigint;
|
|
109
|
+
};
|
|
110
|
+
/** Permission Flags Enum. */
|
|
111
|
+
export declare enum PermissionFlagsBits {
|
|
112
|
+
CreateInstantInvite = "1",
|
|
113
|
+
KickMembers = "2",
|
|
114
|
+
BanMembers = "4",
|
|
115
|
+
Administrator = "8",
|
|
116
|
+
ManageChannels = "16",
|
|
117
|
+
ManageGuild = "32",
|
|
118
|
+
AddReactions = "64",
|
|
119
|
+
ViewAuditLog = "128",
|
|
120
|
+
PrioritySpeaker = "256",
|
|
121
|
+
Stream = "512",
|
|
122
|
+
ViewChannel = "1024",
|
|
123
|
+
SendMessages = "2048",
|
|
124
|
+
SendTTSMessages = "4096",
|
|
125
|
+
ManageMessages = "8192",
|
|
126
|
+
EmbedLinks = "16384",
|
|
127
|
+
AttachFiles = "32768",
|
|
128
|
+
ReadMessageHistory = "65536",
|
|
129
|
+
MentionEveryone = "131072",
|
|
130
|
+
UseExternalEmojis = "262144",
|
|
131
|
+
ViewGuildInsights = "524288",
|
|
132
|
+
Connect = "1048576",
|
|
133
|
+
Speak = "2097152",
|
|
134
|
+
MuteMembers = "4194304",
|
|
135
|
+
DeafenMembers = "8388608",
|
|
136
|
+
MoveMembers = "16777216",
|
|
137
|
+
UseVAD = "33554432",
|
|
138
|
+
ChangeNickname = "67108864",
|
|
139
|
+
ManageNicknames = "134217728",
|
|
140
|
+
ManageRoles = "268435456",
|
|
141
|
+
ManageWebhooks = "536870912",
|
|
142
|
+
ManageGuildExpressions = "1073741824",
|
|
143
|
+
UseApplicationCommands = "2147483648",
|
|
144
|
+
RequestToSpeak = "4294967296",
|
|
145
|
+
ManageEvents = "8589934592",
|
|
146
|
+
ManageThreads = "17179869184",
|
|
147
|
+
CreatePublicThreads = "34359738368",
|
|
148
|
+
CreatePrivateThreads = "68719476736",
|
|
149
|
+
UseExternalStickers = "137438953472",
|
|
150
|
+
SendMessagesInThreads = "274877906944",
|
|
151
|
+
UseEmbeddedActivities = "549755813888",
|
|
152
|
+
ModerateMembers = "1099511627776",
|
|
153
|
+
ViewCreatorMonetizationAnalytics = "2199023255552",
|
|
154
|
+
UseSoundboard = "4398046511104",
|
|
155
|
+
CreateGuildExpressions = "8796093022208",
|
|
156
|
+
CreateEvents = "17592186044416",
|
|
157
|
+
UseExternalSounds = "35184372088832",
|
|
158
|
+
SendVoiceMessages = "70368744177664",
|
|
159
|
+
SendPolls = "562949953421312",
|
|
160
|
+
UseExternalApps = "1125899906842624"
|
|
161
|
+
}
|
|
162
|
+
export type PermissionName = keyof typeof Permission | keyof typeof Permissions | keyof typeof PermissionFlagsBits;
|
|
163
|
+
export type PermissionResolvable = bigint | number | string | PermissionName | PermissionFlagsBits | PermissionSet | PermissionResolvable[];
|
|
164
|
+
/** Immutable permission bitfield with direct boolean getters. */
|
|
165
|
+
export declare class PermissionSet {
|
|
166
|
+
#private;
|
|
167
|
+
/** Permission bitfield. */
|
|
168
|
+
readonly bitfield: bigint;
|
|
169
|
+
/** Creates a permission set. @param value Initial permission bitfield or array of permissions. @throws {RangeError} If the value is negative. @throws {TypeError} If the value is not a valid integer. */
|
|
170
|
+
constructor(value?: PermissionResolvable);
|
|
171
|
+
get createInstantInvite(): boolean;
|
|
172
|
+
get kickMembers(): boolean;
|
|
173
|
+
get banMembers(): boolean;
|
|
174
|
+
get administrator(): boolean;
|
|
175
|
+
get manageChannels(): boolean;
|
|
176
|
+
get manageGuild(): boolean;
|
|
177
|
+
get addReactions(): boolean;
|
|
178
|
+
get viewAuditLog(): boolean;
|
|
179
|
+
get prioritySpeaker(): boolean;
|
|
180
|
+
get stream(): boolean;
|
|
181
|
+
get viewChannel(): boolean;
|
|
182
|
+
get sendMessages(): boolean;
|
|
183
|
+
get sendTTSMessages(): boolean;
|
|
184
|
+
get manageMessages(): boolean;
|
|
185
|
+
get embedLinks(): boolean;
|
|
186
|
+
get attachFiles(): boolean;
|
|
187
|
+
get readMessageHistory(): boolean;
|
|
188
|
+
get mentionEveryone(): boolean;
|
|
189
|
+
get useExternalEmojis(): boolean;
|
|
190
|
+
get viewGuildInsights(): boolean;
|
|
191
|
+
get connect(): boolean;
|
|
192
|
+
get speak(): boolean;
|
|
193
|
+
get muteMembers(): boolean;
|
|
194
|
+
get deafenMembers(): boolean;
|
|
195
|
+
get moveMembers(): boolean;
|
|
196
|
+
get useVAD(): boolean;
|
|
197
|
+
get changeNickname(): boolean;
|
|
198
|
+
get manageNicknames(): boolean;
|
|
199
|
+
get manageRoles(): boolean;
|
|
200
|
+
get manageWebhooks(): boolean;
|
|
201
|
+
get manageGuildExpressions(): boolean;
|
|
202
|
+
get useApplicationCommands(): boolean;
|
|
203
|
+
get requestToSpeak(): boolean;
|
|
204
|
+
get manageEvents(): boolean;
|
|
205
|
+
get manageThreads(): boolean;
|
|
206
|
+
get createPublicThreads(): boolean;
|
|
207
|
+
get createPrivateThreads(): boolean;
|
|
208
|
+
get useExternalStickers(): boolean;
|
|
209
|
+
get sendMessagesInThreads(): boolean;
|
|
210
|
+
get useEmbeddedActivities(): boolean;
|
|
211
|
+
get moderateMembers(): boolean;
|
|
212
|
+
get viewCreatorMonetizationAnalytics(): boolean;
|
|
213
|
+
get useSoundboard(): boolean;
|
|
214
|
+
get createGuildExpressions(): boolean;
|
|
215
|
+
get createEvents(): boolean;
|
|
216
|
+
get useExternalSounds(): boolean;
|
|
217
|
+
get sendVoiceMessages(): boolean;
|
|
218
|
+
get sendPolls(): boolean;
|
|
219
|
+
get useExternalApps(): boolean;
|
|
220
|
+
/** Checks whether all supplied permissions are present (AND). @param permissions Permission names or raw bits. @returns True when every requested permission is present. */
|
|
221
|
+
has(...permissions: PermissionResolvable[]): boolean;
|
|
222
|
+
/** Checks whether any supplied permission is present (OR). @param permissions Permission names or raw bits. @returns True when at least one requested permission is present. */
|
|
223
|
+
any(...permissions: PermissionResolvable[]): boolean;
|
|
224
|
+
/** Returns a new set with permissions added. @param permissions Permission names or raw bits. @returns A new permission set. */
|
|
225
|
+
add(...permissions: PermissionResolvable[]): PermissionSet;
|
|
226
|
+
/** Returns a new set with permissions removed. @param permissions Permission names or raw bits. @returns A new permission set. */
|
|
227
|
+
remove(...permissions: PermissionResolvable[]): PermissionSet;
|
|
228
|
+
/** Checks equality with another permission set or raw bitfield. @param other Permission set or raw bitfield. @returns True when both values are equal. */
|
|
229
|
+
equals(other: PermissionSet | bigint | number | string): boolean;
|
|
230
|
+
/** Returns the decimal permission representation. @returns Decimal permission bitfield. */
|
|
231
|
+
toString(): string;
|
|
232
|
+
/** Returns known permission names contained in this set. @returns Names of all enabled known permissions. */
|
|
233
|
+
toArray(): PermissionName[];
|
|
234
|
+
}
|
|
235
|
+
/** Permissions bitfield alias. */
|
|
236
|
+
export declare class PermissionsBitField extends PermissionSet {
|
|
237
|
+
/** Permission flags bits enum. */
|
|
238
|
+
static readonly Flags: typeof PermissionFlagsBits;
|
|
239
|
+
/** Permission flags constants. */
|
|
240
|
+
static readonly All: {
|
|
241
|
+
readonly createInstantInvite: bigint;
|
|
242
|
+
readonly kickMembers: bigint;
|
|
243
|
+
readonly banMembers: bigint;
|
|
244
|
+
readonly administrator: bigint;
|
|
245
|
+
readonly manageChannels: bigint;
|
|
246
|
+
readonly manageGuild: bigint;
|
|
247
|
+
readonly addReactions: bigint;
|
|
248
|
+
readonly viewAuditLog: bigint;
|
|
249
|
+
readonly prioritySpeaker: bigint;
|
|
250
|
+
readonly stream: bigint;
|
|
251
|
+
readonly viewChannel: bigint;
|
|
252
|
+
readonly sendMessages: bigint;
|
|
253
|
+
readonly sendTTSMessages: bigint;
|
|
254
|
+
readonly manageMessages: bigint;
|
|
255
|
+
readonly embedLinks: bigint;
|
|
256
|
+
readonly attachFiles: bigint;
|
|
257
|
+
readonly readMessageHistory: bigint;
|
|
258
|
+
readonly mentionEveryone: bigint;
|
|
259
|
+
readonly useExternalEmojis: bigint;
|
|
260
|
+
readonly viewGuildInsights: bigint;
|
|
261
|
+
readonly connect: bigint;
|
|
262
|
+
readonly speak: bigint;
|
|
263
|
+
readonly muteMembers: bigint;
|
|
264
|
+
readonly deafenMembers: bigint;
|
|
265
|
+
readonly moveMembers: bigint;
|
|
266
|
+
readonly useVAD: bigint;
|
|
267
|
+
readonly changeNickname: bigint;
|
|
268
|
+
readonly manageNicknames: bigint;
|
|
269
|
+
readonly manageRoles: bigint;
|
|
270
|
+
readonly manageWebhooks: bigint;
|
|
271
|
+
readonly manageGuildExpressions: bigint;
|
|
272
|
+
readonly useApplicationCommands: bigint;
|
|
273
|
+
readonly requestToSpeak: bigint;
|
|
274
|
+
readonly manageEvents: bigint;
|
|
275
|
+
readonly manageThreads: bigint;
|
|
276
|
+
readonly createPublicThreads: bigint;
|
|
277
|
+
readonly createPrivateThreads: bigint;
|
|
278
|
+
readonly useExternalStickers: bigint;
|
|
279
|
+
readonly sendMessagesInThreads: bigint;
|
|
280
|
+
readonly useEmbeddedActivities: bigint;
|
|
281
|
+
readonly moderateMembers: bigint;
|
|
282
|
+
readonly viewCreatorMonetizationAnalytics: bigint;
|
|
283
|
+
readonly useSoundboard: bigint;
|
|
284
|
+
readonly createGuildExpressions: bigint;
|
|
285
|
+
readonly createEvents: bigint;
|
|
286
|
+
readonly useExternalSounds: bigint;
|
|
287
|
+
readonly sendVoiceMessages: bigint;
|
|
288
|
+
readonly sendPolls: bigint;
|
|
289
|
+
readonly useExternalApps: bigint;
|
|
290
|
+
};
|
|
291
|
+
/** Creates a permissions bitfield. @param value Initial permission bitfield or array of permissions. */
|
|
292
|
+
constructor(value?: PermissionResolvable);
|
|
293
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Creates a user mention from a Discord snowflake. */
|
|
2
|
+
export declare function userMention(id: string): string;
|
|
3
|
+
/** Creates a channel mention from a Discord snowflake. */
|
|
4
|
+
export declare function channelMention(id: string): string;
|
|
5
|
+
/** Creates a role mention from a Discord snowflake. */
|
|
6
|
+
export declare function roleMention(id: string): string;
|
|
7
|
+
/** Creates a Discord timestamp tag. */
|
|
8
|
+
export declare function timestamp(unixSeconds: number, style?: string): string;
|
|
9
|
+
/** Escapes Discord markdown control characters. */
|
|
10
|
+
export declare function escapeMarkdown(value: string): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/formatters/src/index.ts
|
|
3
|
+
function userMention(id) {
|
|
4
|
+
return `<@${validateSnowflake(id, "User ID")}>`;
|
|
5
|
+
}
|
|
6
|
+
function channelMention(id) {
|
|
7
|
+
return `<#${validateSnowflake(id, "Channel ID")}>`;
|
|
8
|
+
}
|
|
9
|
+
function roleMention(id) {
|
|
10
|
+
return `<@&${validateSnowflake(id, "Role ID")}>`;
|
|
11
|
+
}
|
|
12
|
+
function timestamp(unixSeconds, style) {
|
|
13
|
+
if (!Number.isFinite(unixSeconds))
|
|
14
|
+
throw new TypeError("Timestamp must be a finite Unix timestamp.");
|
|
15
|
+
if (style !== undefined && !/^[tTdDfFR]$/.test(style))
|
|
16
|
+
throw new RangeError("Invalid Discord timestamp style.");
|
|
17
|
+
return `<t:${Math.floor(unixSeconds)}${style ? `:${style}` : ""}>`;
|
|
18
|
+
}
|
|
19
|
+
function escapeMarkdown(value) {
|
|
20
|
+
return value.replace(/[\\*_`~|>]/g, "\\$&");
|
|
21
|
+
}
|
|
22
|
+
function validateSnowflake(id, field) {
|
|
23
|
+
const len = id.length;
|
|
24
|
+
if (len < 1 || len > 20) {
|
|
25
|
+
throw new TypeError(`${field} must be a valid Discord snowflake.`);
|
|
26
|
+
}
|
|
27
|
+
for (let i = 0;i < len; i++) {
|
|
28
|
+
const code = id.charCodeAt(i);
|
|
29
|
+
if (code < 48 || code > 57) {
|
|
30
|
+
throw new TypeError(`${field} must be a valid Discord snowflake.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return id;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
channelMention,
|
|
37
|
+
escapeMarkdown,
|
|
38
|
+
roleMention,
|
|
39
|
+
timestamp,
|
|
40
|
+
userMention
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//# debugId=73DCA2F128C2B50664756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/formatters/src/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/** Creates a user mention from a Discord snowflake. */\r\nexport function userMention(id: string): string {\r\n return `<@${validateSnowflake(id, \"User ID\")}>`;\r\n}\r\n\r\n/** Creates a channel mention from a Discord snowflake. */\r\nexport function channelMention(id: string): string {\r\n return `<#${validateSnowflake(id, \"Channel ID\")}>`;\r\n}\r\n\r\n/** Creates a role mention from a Discord snowflake. */\r\nexport function roleMention(id: string): string {\r\n return `<@&${validateSnowflake(id, \"Role ID\")}>`;\r\n}\r\n\r\n/** Creates a Discord timestamp tag. */\r\nexport function timestamp(unixSeconds: number, style?: string): string {\r\n if (!Number.isFinite(unixSeconds))\r\n throw new TypeError(\"Timestamp must be a finite Unix timestamp.\");\r\n if (style !== undefined && !/^[tTdDfFR]$/.test(style))\r\n throw new RangeError(\"Invalid Discord timestamp style.\");\r\n return `<t:${Math.floor(unixSeconds)}${style ? `:${style}` : \"\"}>`;\r\n}\r\n\r\n/** Escapes Discord markdown control characters. */\r\nexport function escapeMarkdown(value: string): string {\r\n return value.replace(/[\\\\*_`~|>]/g, \"\\\\$&\");\r\n}\r\n\r\nfunction validateSnowflake(id: string, field: string): string {\r\n const len = id.length;\r\n if (len < 1 || len > 20) {\r\n throw new TypeError(`${field} must be a valid Discord snowflake.`);\r\n }\r\n for (let i = 0; i < len; i++) {\r\n const code = id.charCodeAt(i);\r\n if (code < 48 || code > 57) {\r\n throw new TypeError(`${field} must be a valid Discord snowflake.`);\r\n }\r\n }\r\n return id;\r\n}\r\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AACO,SAAS,WAAW,CAAC,IAAoB;AAAA,EAC9C,OAAO,KAAK,kBAAkB,IAAI,SAAS;AAAA;AAItC,SAAS,cAAc,CAAC,IAAoB;AAAA,EACjD,OAAO,KAAK,kBAAkB,IAAI,YAAY;AAAA;AAIzC,SAAS,WAAW,CAAC,IAAoB;AAAA,EAC9C,OAAO,MAAM,kBAAkB,IAAI,SAAS;AAAA;AAIvC,SAAS,SAAS,CAAC,aAAqB,OAAwB;AAAA,EACrE,IAAI,CAAC,OAAO,SAAS,WAAW;AAAA,IAC9B,MAAM,IAAI,UAAU,4CAA4C;AAAA,EAClE,IAAI,UAAU,aAAa,CAAC,cAAc,KAAK,KAAK;AAAA,IAClD,MAAM,IAAI,WAAW,kCAAkC;AAAA,EACzD,OAAO,MAAM,KAAK,MAAM,WAAW,IAAI,QAAQ,IAAI,UAAU;AAAA;AAIxD,SAAS,cAAc,CAAC,OAAuB;AAAA,EACpD,OAAO,MAAM,QAAQ,eAAe,MAAM;AAAA;AAG5C,SAAS,iBAAiB,CAAC,IAAY,OAAuB;AAAA,EAC5D,MAAM,MAAM,GAAG;AAAA,EACf,IAAI,MAAM,KAAK,MAAM,IAAI;AAAA,IACvB,MAAM,IAAI,UAAU,GAAG,0CAA0C;AAAA,EACnE;AAAA,EACA,SAAS,IAAI,EAAG,IAAI,KAAK,KAAK;AAAA,IAC5B,MAAM,OAAO,GAAG,WAAW,CAAC;AAAA,IAC5B,IAAI,OAAO,MAAM,OAAO,IAAI;AAAA,MAC1B,MAAM,IAAI,UAAU,GAAG,0CAA0C;AAAA,IACnE;AAAA,EACF;AAAA,EACA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "73DCA2F128C2B50664756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A typed handler registry for Lunibee events. */
|
|
2
|
+
export declare class HandlerRegistry<Events extends {
|
|
3
|
+
[K in keyof Events]: unknown[];
|
|
4
|
+
}> {
|
|
5
|
+
#private;
|
|
6
|
+
/** Registers a handler for an event. @param event Event key. @param handler Handler callback. @returns This registry. */
|
|
7
|
+
on<K extends keyof Events>(event: K, handler: (...args: Events[K]) => unknown): this;
|
|
8
|
+
/** Registers a one-shot handler. @param event Event key. @param handler Handler callback. @returns This registry. */
|
|
9
|
+
once<K extends keyof Events>(event: K, handler: (...args: Events[K]) => unknown): this;
|
|
10
|
+
/** Removes a handler. @param event Event key. @param handler Handler callback. @returns This registry. */
|
|
11
|
+
off<K extends keyof Events>(event: K, handler: (...args: Events[K]) => unknown): this;
|
|
12
|
+
/** Dispatches an event to registered handlers. @param event Event key. @param args Event arguments. @returns A promise fulfilled after handlers complete. */
|
|
13
|
+
dispatch<K extends keyof Events>(event: K, ...args: Events[K]): Promise<void>;
|
|
14
|
+
/** Emits an event using the conventional emitter name. @param event Event key. @param args Event arguments. @returns A promise fulfilled after handlers complete. */
|
|
15
|
+
emit<K extends keyof Events>(event: K, ...args: Events[K]): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/handlers/src/index.ts
|
|
3
|
+
class HandlerRegistry {
|
|
4
|
+
#handlers = new Map;
|
|
5
|
+
on(event, handler) {
|
|
6
|
+
let handlers = this.#handlers.get(event);
|
|
7
|
+
if (!handlers) {
|
|
8
|
+
handlers = new Set;
|
|
9
|
+
this.#handlers.set(event, handlers);
|
|
10
|
+
}
|
|
11
|
+
handlers.add(handler);
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
once(event, handler) {
|
|
15
|
+
const wrapped = (...args) => {
|
|
16
|
+
this.off(event, wrapped);
|
|
17
|
+
return handler(...args);
|
|
18
|
+
};
|
|
19
|
+
return this.on(event, wrapped);
|
|
20
|
+
}
|
|
21
|
+
off(event, handler) {
|
|
22
|
+
this.#handlers.get(event)?.delete(handler);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
async dispatch(event, ...args) {
|
|
26
|
+
for (const handler of this.#handlers.get(event) ?? [])
|
|
27
|
+
await handler(...args);
|
|
28
|
+
}
|
|
29
|
+
emit(event, ...args) {
|
|
30
|
+
return this.dispatch(event, ...args);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
HandlerRegistry
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//# debugId=C1392DF8895F311564756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/handlers/src/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/** A typed handler registry for Lunibee events. */\nexport class HandlerRegistry<\n Events extends { [K in keyof Events]: unknown[] },\n> {\n /** Registered event handlers. */\n readonly #handlers = new Map<\n keyof Events,\n Set<(...args: any[]) => unknown>\n >();\n /** Registers a handler for an event. @param event Event key. @param handler Handler callback. @returns This registry. */\n public on<K extends keyof Events>(\n event: K,\n handler: (...args: Events[K]) => unknown,\n ): this {\n let handlers = this.#handlers.get(event);\n if (!handlers) {\n handlers = new Set();\n this.#handlers.set(event, handlers);\n }\n handlers.add(handler);\n return this;\n }\n /** Registers a one-shot handler. @param event Event key. @param handler Handler callback. @returns This registry. */\n public once<K extends keyof Events>(\n event: K,\n handler: (...args: Events[K]) => unknown,\n ): this {\n const wrapped = (...args: Events[K]) => {\n this.off(event, wrapped);\n return handler(...args);\n };\n return this.on(event, wrapped);\n }\n /** Removes a handler. @param event Event key. @param handler Handler callback. @returns This registry. */\n public off<K extends keyof Events>(\n event: K,\n handler: (...args: Events[K]) => unknown,\n ): this {\n this.#handlers.get(event)?.delete(handler);\n return this;\n }\n /** Dispatches an event to registered handlers. @param event Event key. @param args Event arguments. @returns A promise fulfilled after handlers complete. */\n public async dispatch<K extends keyof Events>(\n event: K,\n ...args: Events[K]\n ): Promise<void> {\n for (const handler of this.#handlers.get(event) ?? [])\n await handler(...args);\n }\n /** Emits an event using the conventional emitter name. @param event Event key. @param args Event arguments. @returns A promise fulfilled after handlers complete. */\n public emit<K extends keyof Events>(\n event: K,\n ...args: Events[K]\n ): Promise<void> {\n return this.dispatch(event, ...args);\n }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AACO,MAAM,gBAEX;AAAA,EAES,YAAY,IAAI;AAAA,EAKlB,EAA0B,CAC/B,OACA,SACM;AAAA,IACN,IAAI,WAAW,KAAK,UAAU,IAAI,KAAK;AAAA,IACvC,IAAI,CAAC,UAAU;AAAA,MACb,WAAW,IAAI;AAAA,MACf,KAAK,UAAU,IAAI,OAAO,QAAQ;AAAA,IACpC;AAAA,IACA,SAAS,IAAI,OAAO;AAAA,IACpB,OAAO;AAAA;AAAA,EAGF,IAA4B,CACjC,OACA,SACM;AAAA,IACN,MAAM,UAAU,IAAI,SAAoB;AAAA,MACtC,KAAK,IAAI,OAAO,OAAO;AAAA,MACvB,OAAO,QAAQ,GAAG,IAAI;AAAA;AAAA,IAExB,OAAO,KAAK,GAAG,OAAO,OAAO;AAAA;AAAA,EAGxB,GAA2B,CAChC,OACA,SACM;AAAA,IACN,KAAK,UAAU,IAAI,KAAK,GAAG,OAAO,OAAO;AAAA,IACzC,OAAO;AAAA;AAAA,OAGI,SAAgC,CAC3C,UACG,MACY;AAAA,IACf,WAAW,WAAW,KAAK,UAAU,IAAI,KAAK,KAAK,CAAC;AAAA,MAClD,MAAM,QAAQ,GAAG,IAAI;AAAA;AAAA,EAGlB,IAA4B,CACjC,UACG,MACY;AAAA,IACf,OAAO,KAAK,SAAS,OAAO,GAAG,IAAI;AAAA;AAEvC;",
|
|
8
|
+
"debugId": "C1392DF8895F311564756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -11,35 +11,8 @@ export * from "@lunibee/types";
|
|
|
11
11
|
export * from "@lunibee/utils";
|
|
12
12
|
export * from "@lunibee/voice";
|
|
13
13
|
export * from "@lunibee/ws";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
CommandInteraction,
|
|
18
|
-
ComponentInteraction,
|
|
19
|
-
ModalSubmitInteraction,
|
|
20
|
-
AutocompleteInteraction,
|
|
21
|
-
Interaction,
|
|
22
|
-
GuildMember,
|
|
23
|
-
Role,
|
|
24
|
-
TextChannel,
|
|
25
|
-
Message,
|
|
26
|
-
} from "@lunibee/structures";
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
EmbedBuilder,
|
|
30
|
-
SlashCommandBuilder,
|
|
31
|
-
ButtonBuilder,
|
|
32
|
-
ButtonStyle,
|
|
33
|
-
StringSelectBuilder,
|
|
34
|
-
EntitySelectBuilder,
|
|
35
|
-
ModalBuilder,
|
|
36
|
-
TextInputBuilder,
|
|
37
|
-
TextInputStyle,
|
|
38
|
-
ActionRowBuilder,
|
|
39
|
-
AttachmentBuilder,
|
|
40
|
-
ApplicationCommandOptionType,
|
|
41
|
-
} from "@lunibee/builders";
|
|
42
|
-
|
|
14
|
+
export { CommandInteraction, ComponentInteraction, ModalSubmitInteraction, AutocompleteInteraction, Interaction, GuildMember, Role, TextChannel, Message, } from "@lunibee/structures";
|
|
15
|
+
export { EmbedBuilder, SlashCommandBuilder, ButtonBuilder, ButtonStyle, StringSelectBuilder, EntitySelectBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, AttachmentBuilder, ApplicationCommandOptionType, } from "@lunibee/builders";
|
|
43
16
|
export { Gateway } from "@lunibee/ws";
|
|
44
17
|
export type { GatewayOptions } from "@lunibee/ws";
|
|
45
18
|
export { Collection, Cache } from "@lunibee/collection";
|