@jubbio/core 1.0.0

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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +166 -0
  3. package/dist/Client.d.ts +147 -0
  4. package/dist/Client.js +471 -0
  5. package/dist/builders/ActionRowBuilder.d.ts +53 -0
  6. package/dist/builders/ActionRowBuilder.js +68 -0
  7. package/dist/builders/ButtonBuilder.d.ts +77 -0
  8. package/dist/builders/ButtonBuilder.js +96 -0
  9. package/dist/builders/EmbedBuilder.d.ts +157 -0
  10. package/dist/builders/EmbedBuilder.js +199 -0
  11. package/dist/builders/ModalBuilder.d.ts +122 -0
  12. package/dist/builders/ModalBuilder.js +162 -0
  13. package/dist/builders/SelectMenuBuilder.d.ts +123 -0
  14. package/dist/builders/SelectMenuBuilder.js +165 -0
  15. package/dist/builders/SlashCommandBuilder.d.ts +197 -0
  16. package/dist/builders/SlashCommandBuilder.js +324 -0
  17. package/dist/builders/index.d.ts +9 -0
  18. package/dist/builders/index.js +26 -0
  19. package/dist/enums.d.ts +196 -0
  20. package/dist/enums.js +216 -0
  21. package/dist/index.d.ts +25 -0
  22. package/dist/index.js +128 -0
  23. package/dist/managers/BaseManager.d.ts +69 -0
  24. package/dist/managers/BaseManager.js +106 -0
  25. package/dist/managers/ChannelManager.d.ts +98 -0
  26. package/dist/managers/ChannelManager.js +209 -0
  27. package/dist/managers/GuildMemberManager.d.ts +74 -0
  28. package/dist/managers/GuildMemberManager.js +156 -0
  29. package/dist/managers/RoleManager.d.ts +84 -0
  30. package/dist/managers/RoleManager.js +207 -0
  31. package/dist/managers/index.d.ts +7 -0
  32. package/dist/managers/index.js +24 -0
  33. package/dist/rest/REST.d.ts +483 -0
  34. package/dist/rest/REST.js +805 -0
  35. package/dist/rest/index.d.ts +1 -0
  36. package/dist/rest/index.js +18 -0
  37. package/dist/sharding/ShardingManager.d.ts +179 -0
  38. package/dist/sharding/ShardingManager.js +375 -0
  39. package/dist/sharding/index.d.ts +4 -0
  40. package/dist/sharding/index.js +21 -0
  41. package/dist/structures/Channel.d.ts +120 -0
  42. package/dist/structures/Channel.js +224 -0
  43. package/dist/structures/Collection.d.ts +53 -0
  44. package/dist/structures/Collection.js +115 -0
  45. package/dist/structures/Guild.d.ts +59 -0
  46. package/dist/structures/Guild.js +90 -0
  47. package/dist/structures/GuildMember.d.ts +130 -0
  48. package/dist/structures/GuildMember.js +208 -0
  49. package/dist/structures/Interaction.d.ts +224 -0
  50. package/dist/structures/Interaction.js +404 -0
  51. package/dist/structures/Message.d.ts +93 -0
  52. package/dist/structures/Message.js +145 -0
  53. package/dist/structures/User.d.ts +37 -0
  54. package/dist/structures/User.js +65 -0
  55. package/dist/structures/index.d.ts +7 -0
  56. package/dist/structures/index.js +25 -0
  57. package/dist/structures.d.ts +1 -0
  58. package/dist/structures.js +19 -0
  59. package/dist/types.d.ts +255 -0
  60. package/dist/types.js +3 -0
  61. package/dist/utils/BitField.d.ts +66 -0
  62. package/dist/utils/BitField.js +138 -0
  63. package/dist/utils/Collection.d.ts +116 -0
  64. package/dist/utils/Collection.js +265 -0
  65. package/dist/utils/Collector.d.ts +152 -0
  66. package/dist/utils/Collector.js +314 -0
  67. package/dist/utils/DataResolver.d.ts +61 -0
  68. package/dist/utils/DataResolver.js +146 -0
  69. package/dist/utils/Formatters.d.ts +145 -0
  70. package/dist/utils/Formatters.js +213 -0
  71. package/dist/utils/IntentsBitField.d.ts +85 -0
  72. package/dist/utils/IntentsBitField.js +99 -0
  73. package/dist/utils/Partials.d.ts +105 -0
  74. package/dist/utils/Partials.js +149 -0
  75. package/dist/utils/PermissionsBitField.d.ts +118 -0
  76. package/dist/utils/PermissionsBitField.js +145 -0
  77. package/dist/utils/SnowflakeUtil.d.ts +63 -0
  78. package/dist/utils/SnowflakeUtil.js +93 -0
  79. package/dist/utils/Sweepers.d.ts +127 -0
  80. package/dist/utils/Sweepers.js +270 -0
  81. package/dist/utils/index.d.ts +13 -0
  82. package/dist/utils/index.js +30 -0
  83. package/package.json +37 -0
@@ -0,0 +1,483 @@
1
+ import { APIMessage, APIApplicationCommand, APIEmbed } from '../types';
2
+ /**
3
+ * Mention data structure for our system
4
+ */
5
+ export interface MentionUser {
6
+ id: number;
7
+ username: string;
8
+ }
9
+ export interface MentionRole {
10
+ id: string;
11
+ name?: string;
12
+ }
13
+ export interface MentionsData {
14
+ users?: MentionUser[];
15
+ roles?: MentionRole[];
16
+ everyone?: boolean;
17
+ }
18
+ /**
19
+ * User cache entry
20
+ */
21
+ interface CachedUser {
22
+ id: number;
23
+ username: string;
24
+ displayName?: string;
25
+ cachedAt: number;
26
+ }
27
+ /**
28
+ * REST API client for Jubbio
29
+ */
30
+ export declare class REST {
31
+ private baseUrl;
32
+ private token;
33
+ private userCache;
34
+ private readonly USER_CACHE_TTL;
35
+ constructor(baseUrl?: string);
36
+ /**
37
+ * Cache a user for mention resolution
38
+ * Bot'lar interaction'dan gelen user bilgisini cache'leyebilir
39
+ */
40
+ cacheUser(user: {
41
+ id: string | number;
42
+ username: string;
43
+ displayName?: string;
44
+ display_name?: string;
45
+ }): void;
46
+ /**
47
+ * Cache multiple users
48
+ */
49
+ cacheUsers(users: Array<{
50
+ id: string | number;
51
+ username: string;
52
+ displayName?: string;
53
+ display_name?: string;
54
+ }>): void;
55
+ /**
56
+ * Get cached user by ID
57
+ */
58
+ getCachedUser(userId: number): CachedUser | undefined;
59
+ /**
60
+ * Format a user mention
61
+ * Returns both the text format and mentions data
62
+ *
63
+ * @example
64
+ * const mention = rest.formatMention(user);
65
+ * // mention.text = "@ilkay"
66
+ * // mention.data = { users: [{ id: 1, username: "ilkay" }] }
67
+ */
68
+ formatMention(user: {
69
+ id: string | number;
70
+ username: string;
71
+ }): {
72
+ text: string;
73
+ data: MentionsData;
74
+ };
75
+ /**
76
+ * Parse mentions (<@ID>) and convert to our format (@username)
77
+ * Also builds the mentions data structure
78
+ *
79
+ * @param content - Message content with mentions
80
+ * @param existingMentions - Existing mentions data to merge with
81
+ * @returns Processed content and mentions data
82
+ */
83
+ private processMentions;
84
+ /**
85
+ * Prepare message data with processed mentions
86
+ * Automatically converts mentions to our format
87
+ */
88
+ private prepareMessageData;
89
+ /**
90
+ * Set the bot token
91
+ */
92
+ setToken(token: string): this;
93
+ /**
94
+ * Make an authenticated request
95
+ */
96
+ private request;
97
+ /**
98
+ * Create a message in a channel
99
+ * Automatically processes mentions (<@ID>) to our format (@username)
100
+ *
101
+ * @example
102
+ * // Mention style (auto-converted):
103
+ * await rest.createMessage(guildId, channelId, {
104
+ * content: 'Hello <@123>!', // Becomes "Hello @username!"
105
+ * });
106
+ *
107
+ * // Our native format:
108
+ * await rest.createMessage(guildId, channelId, {
109
+ * content: 'Hello @ilkay!',
110
+ * mentions: { users: [{ id: 123, username: 'ilkay' }] }
111
+ * });
112
+ */
113
+ createMessage(guildIdOrChannelId: string, channelIdOrData: string | {
114
+ content?: string;
115
+ embeds?: APIEmbed[];
116
+ components?: any[];
117
+ mentions?: MentionsData;
118
+ files?: Array<{
119
+ name: string;
120
+ data: Buffer;
121
+ }>;
122
+ message_reference?: {
123
+ message_id: string;
124
+ };
125
+ interactionId?: string;
126
+ }, data?: {
127
+ content?: string;
128
+ embeds?: APIEmbed[];
129
+ components?: any[];
130
+ mentions?: MentionsData;
131
+ files?: Array<{
132
+ name: string;
133
+ data: Buffer;
134
+ }>;
135
+ message_reference?: {
136
+ message_id: string;
137
+ };
138
+ interactionId?: string;
139
+ }): Promise<APIMessage>;
140
+ /**
141
+ * Create an ephemeral message that is only visible to a specific user
142
+ * Ephemeral messages are NOT saved to database - they are only sent via WebSocket
143
+ *
144
+ * @example
145
+ * // Send a warning only visible to the user
146
+ * await rest.createEphemeralMessage(guildId, channelId, targetUserId, {
147
+ * embeds: [warningEmbed]
148
+ * });
149
+ */
150
+ createEphemeralMessage(guildId: string, channelId: string, targetUserId: string | number, data: {
151
+ content?: string;
152
+ embeds?: APIEmbed[];
153
+ }): Promise<{
154
+ id: string;
155
+ ephemeral: boolean;
156
+ flags: number;
157
+ }>;
158
+ /**
159
+ * Create a DM message
160
+ */
161
+ createDMMessage(channelId: string, data: {
162
+ content?: string;
163
+ embeds?: APIEmbed[];
164
+ }): Promise<APIMessage>;
165
+ /**
166
+ * Edit a message
167
+ * Automatically processes mentions
168
+ */
169
+ editMessage(guildId: string, channelId: string, messageId: string, data: {
170
+ content?: string;
171
+ embeds?: APIEmbed[];
172
+ mentions?: MentionsData;
173
+ }): Promise<APIMessage>;
174
+ /**
175
+ * Delete a message
176
+ */
177
+ deleteMessage(guildId: string, channelId: string, messageId: string): Promise<void>;
178
+ /**
179
+ * Add a reaction to a message
180
+ */
181
+ addReaction(guildId: string, channelId: string, messageId: string, emoji: string): Promise<void>;
182
+ /**
183
+ * Upload an attachment to a channel
184
+ */
185
+ uploadAttachment(guildId: string, channelId: string, file: {
186
+ name: string;
187
+ data: Buffer;
188
+ contentType?: string;
189
+ }): Promise<{
190
+ id: string;
191
+ url: string;
192
+ filename: string;
193
+ }>;
194
+ /**
195
+ * Create a message with a file attachment
196
+ */
197
+ createMessageWithFile(guildId: string, channelId: string, data: {
198
+ content?: string;
199
+ file: {
200
+ name: string;
201
+ data: Buffer;
202
+ contentType?: string;
203
+ };
204
+ interactionId?: string;
205
+ }): Promise<APIMessage>;
206
+ /**
207
+ * Create an interaction response
208
+ * Automatically processes mentions in content and embeds
209
+ */
210
+ createInteractionResponse(interactionId: string, token: string, data: {
211
+ type: number;
212
+ data?: any;
213
+ }): Promise<void>;
214
+ /**
215
+ * Edit the original interaction response
216
+ * If files are provided, creates a new message with files (since webhook edit doesn't support file upload)
217
+ * Automatically processes mentions
218
+ */
219
+ editInteractionResponse(token: string, data: {
220
+ content?: string;
221
+ embeds?: APIEmbed[];
222
+ components?: any[];
223
+ mentions?: MentionsData;
224
+ files?: Array<{
225
+ name: string;
226
+ data: Buffer;
227
+ contentType?: string;
228
+ }>;
229
+ }, guildId?: string, channelId?: string, interactionId?: string): Promise<void>;
230
+ /**
231
+ * Delete the original interaction response
232
+ */
233
+ deleteInteractionResponse(token: string): Promise<void>;
234
+ /**
235
+ * Create a followup message
236
+ * Automatically processes mentions
237
+ */
238
+ createFollowup(token: string, data: {
239
+ content?: string;
240
+ embeds?: APIEmbed[];
241
+ mentions?: MentionsData;
242
+ flags?: number;
243
+ }): Promise<void>;
244
+ /**
245
+ * Register global application commands
246
+ */
247
+ registerGlobalCommands(commands: APIApplicationCommand[]): Promise<void>;
248
+ /**
249
+ * Register guild-specific commands
250
+ */
251
+ registerGuildCommands(guildId: string, commands: APIApplicationCommand[]): Promise<void>;
252
+ /**
253
+ * Delete a global command
254
+ */
255
+ deleteGlobalCommand(commandId: string): Promise<void>;
256
+ private applicationId;
257
+ /**
258
+ * Set the application ID
259
+ */
260
+ setApplicationId(id: string): void;
261
+ /**
262
+ * Get the application ID
263
+ */
264
+ private getApplicationId;
265
+ /**
266
+ * Create a channel in a guild
267
+ */
268
+ createChannel(guildId: string, data: {
269
+ name: string;
270
+ type?: number;
271
+ parent_id?: string | null;
272
+ category_id?: string | null;
273
+ permission_overwrites?: Array<{
274
+ id: string;
275
+ type: number;
276
+ allow?: string;
277
+ deny?: string;
278
+ }>;
279
+ }): Promise<{
280
+ id: string;
281
+ name: string;
282
+ }>;
283
+ /**
284
+ * Delete a channel
285
+ */
286
+ /**
287
+ * Delete a channel
288
+ */
289
+ deleteChannel(guildId: string, channelId: string): Promise<void>;
290
+ /**
291
+ * Edit channel permission overwrites
292
+ */
293
+ editChannelPermissions(channelId: string, overwriteId: string, data: {
294
+ type: number;
295
+ allow?: string;
296
+ deny?: string;
297
+ }): Promise<void>;
298
+ /**
299
+ * Delete channel permission overwrite
300
+ */
301
+ deleteChannelPermission(channelId: string, overwriteId: string): Promise<void>;
302
+ /**
303
+ * Get messages from a channel
304
+ */
305
+ getMessages(guildId: string, channelId: string, options?: {
306
+ limit?: number;
307
+ before?: string;
308
+ after?: string;
309
+ }): Promise<APIMessage[]>;
310
+ /**
311
+ * Get a guild member
312
+ */
313
+ getMember(guildId: string, userId: string): Promise<any>;
314
+ /**
315
+ * Timeout a guild member
316
+ */
317
+ timeoutMember(guildId: string, userId: string, duration: number | null, reason?: string): Promise<void>;
318
+ /**
319
+ * Kick a guild member
320
+ */
321
+ kickMember(guildId: string, userId: string, reason?: string): Promise<void>;
322
+ /**
323
+ * Ban a guild member
324
+ */
325
+ banMember(guildId: string, userId: string, options?: {
326
+ deleteMessageDays?: number;
327
+ deleteMessageSeconds?: number;
328
+ reason?: string;
329
+ }): Promise<void>;
330
+ /**
331
+ * Unban a user
332
+ */
333
+ unbanMember(guildId: string, userId: string, reason?: string): Promise<void>;
334
+ /**
335
+ * Edit a guild member
336
+ */
337
+ editMember(guildId: string, userId: string, data: {
338
+ nick?: string | null;
339
+ roles?: string[];
340
+ mute?: boolean;
341
+ deaf?: boolean;
342
+ channel_id?: string | null;
343
+ communication_disabled_until?: string | null;
344
+ reason?: string;
345
+ }): Promise<any>;
346
+ /**
347
+ * Add a role to a member
348
+ */
349
+ addMemberRole(guildId: string, userId: string, roleId: string, reason?: string): Promise<void>;
350
+ /**
351
+ * Remove a role from a member
352
+ */
353
+ removeMemberRole(guildId: string, userId: string, roleId: string, reason?: string): Promise<void>;
354
+ /**
355
+ * Bulk delete messages
356
+ */
357
+ bulkDeleteMessages(guildId: string, channelId: string, messageIds: string[]): Promise<void>;
358
+ /**
359
+ * Get a guild
360
+ */
361
+ getGuild(guildId: string): Promise<any>;
362
+ /**
363
+ * Get guild channels
364
+ */
365
+ getGuildChannels(guildId: string): Promise<any[]>;
366
+ /**
367
+ * Get guild roles
368
+ */
369
+ getRoles(guildId: string): Promise<any[]>;
370
+ /**
371
+ * Create a role
372
+ */
373
+ createRole(guildId: string, data: {
374
+ name?: string;
375
+ color?: number;
376
+ hoist?: boolean;
377
+ mentionable?: boolean;
378
+ permissions?: string;
379
+ }): Promise<any>;
380
+ /**
381
+ * Edit a role
382
+ */
383
+ editRole(guildId: string, roleId: string, data: {
384
+ name?: string;
385
+ color?: number;
386
+ hoist?: boolean;
387
+ mentionable?: boolean;
388
+ permissions?: string;
389
+ }): Promise<any>;
390
+ /**
391
+ * Delete a role
392
+ */
393
+ deleteRole(guildId: string, roleId: string): Promise<void>;
394
+ /**
395
+ * Get guild emojis
396
+ */
397
+ getEmojis(guildId: string): Promise<any[]>;
398
+ /**
399
+ * Get guild bans
400
+ */
401
+ getBans(guildId: string): Promise<any[]>;
402
+ /**
403
+ * Get a specific ban
404
+ */
405
+ getBan(guildId: string, userId: string): Promise<any>;
406
+ /**
407
+ * Get guild invites
408
+ */
409
+ getGuildInvites(guildId: string): Promise<any[]>;
410
+ /**
411
+ * Create a thread from a message
412
+ */
413
+ createThreadFromMessage(guildId: string, channelId: string, messageId: string, data: {
414
+ name: string;
415
+ auto_archive_duration?: number;
416
+ }): Promise<any>;
417
+ /**
418
+ * Create a thread without a message
419
+ */
420
+ createThread(guildId: string, channelId: string, data: {
421
+ name: string;
422
+ type?: number;
423
+ auto_archive_duration?: number;
424
+ invitable?: boolean;
425
+ }): Promise<any>;
426
+ /**
427
+ * Join a thread
428
+ */
429
+ joinThread(channelId: string): Promise<void>;
430
+ /**
431
+ * Leave a thread
432
+ */
433
+ leaveThread(channelId: string): Promise<void>;
434
+ /**
435
+ * Pin a message
436
+ */
437
+ pinMessage(guildId: string, channelId: string, messageId: string): Promise<void>;
438
+ /**
439
+ * Unpin a message
440
+ */
441
+ unpinMessage(guildId: string, channelId: string, messageId: string): Promise<void>;
442
+ /**
443
+ * Get pinned messages
444
+ */
445
+ getPinnedMessages(guildId: string, channelId: string): Promise<APIMessage[]>;
446
+ /**
447
+ * Get a user
448
+ */
449
+ getUser(userId: string): Promise<any>;
450
+ /**
451
+ * Get current bot user
452
+ */
453
+ getCurrentUser(): Promise<any>;
454
+ /**
455
+ * Create an invite
456
+ */
457
+ createInvite(guildId: string, channelId: string, data?: {
458
+ max_age?: number;
459
+ max_uses?: number;
460
+ temporary?: boolean;
461
+ unique?: boolean;
462
+ }): Promise<any>;
463
+ /**
464
+ * Delete an invite
465
+ */
466
+ deleteInvite(inviteCode: string): Promise<void>;
467
+ /**
468
+ * Get an invite
469
+ */
470
+ getInvite(inviteCode: string): Promise<any>;
471
+ /**
472
+ * Get channel webhooks
473
+ */
474
+ getChannelWebhooks(guildId: string, channelId: string): Promise<any[]>;
475
+ /**
476
+ * Create a webhook
477
+ */
478
+ createWebhook(guildId: string, channelId: string, data: {
479
+ name: string;
480
+ avatar?: string;
481
+ }): Promise<any>;
482
+ }
483
+ export {};