library.dr-conversion 0.1.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.
- package/API.md +592 -0
- package/CHANGELOG.md +96 -0
- package/LICENSE +21 -0
- package/README.md +445 -0
- package/cli.js +186 -0
- package/dist/client.d.ts +31 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +99 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/base.d.ts +33 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +64 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/discord/converters.d.ts +39 -0
- package/dist/providers/discord/converters.d.ts.map +1 -0
- package/dist/providers/discord/converters.js +471 -0
- package/dist/providers/discord/converters.js.map +1 -0
- package/dist/providers/discord/provider.d.ts +26 -0
- package/dist/providers/discord/provider.d.ts.map +1 -0
- package/dist/providers/discord/provider.js +336 -0
- package/dist/providers/discord/provider.js.map +1 -0
- package/dist/providers/discord/types.d.ts +11 -0
- package/dist/providers/discord/types.d.ts.map +1 -0
- package/dist/providers/discord/types.js +24 -0
- package/dist/providers/discord/types.js.map +1 -0
- package/dist/providers/root/converters.d.ts +13 -0
- package/dist/providers/root/converters.d.ts.map +1 -0
- package/dist/providers/root/converters.js +215 -0
- package/dist/providers/root/converters.js.map +1 -0
- package/dist/providers/root/http-client.d.ts +15 -0
- package/dist/providers/root/http-client.d.ts.map +1 -0
- package/dist/providers/root/http-client.js +84 -0
- package/dist/providers/root/http-client.js.map +1 -0
- package/dist/providers/root/provider.d.ts +25 -0
- package/dist/providers/root/provider.d.ts.map +1 -0
- package/dist/providers/root/provider.js +118 -0
- package/dist/providers/root/provider.js.map +1 -0
- package/dist/providers/root/types.d.ts +171 -0
- package/dist/providers/root/types.d.ts.map +1 -0
- package/dist/providers/root/types.js +63 -0
- package/dist/providers/root/types.js.map +1 -0
- package/dist/providers/root/websocket-client.d.ts +23 -0
- package/dist/providers/root/websocket-client.d.ts.map +1 -0
- package/dist/providers/root/websocket-client.js +176 -0
- package/dist/providers/root/websocket-client.js.map +1 -0
- package/dist/types/common.d.ts +77 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +3 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/embeds.d.ts +93 -0
- package/dist/types/embeds.d.ts.map +1 -0
- package/dist/types/embeds.js +19 -0
- package/dist/types/embeds.js.map +1 -0
- package/dist/types/events.d.ts +28 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +3 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/platform.d.ts +39 -0
- package/dist/types/platform.d.ts.map +1 -0
- package/dist/types/platform.js +3 -0
- package/dist/types/platform.js.map +1 -0
- package/dist/utils/errors.d.ts +35 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +86 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +64 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +90 -0
package/API.md
ADDED
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
# API Quick Reference
|
|
2
|
+
|
|
3
|
+
Quick reference guide for the Library.DR-Conversion API.
|
|
4
|
+
|
|
5
|
+
## 🚀 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install Library.DR-Conversion
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 📝 Basic Setup
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { UnifiedClient, LogLevel } from 'Library.DR-Conversion';
|
|
15
|
+
|
|
16
|
+
const client = new UnifiedClient({
|
|
17
|
+
platform: 'discord', // or 'root'
|
|
18
|
+
config: {
|
|
19
|
+
token: 'YOUR_BOT_TOKEN'
|
|
20
|
+
},
|
|
21
|
+
logLevel: LogLevel.INFO // optional
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await client.connect();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 📡 Events
|
|
28
|
+
|
|
29
|
+
### Core Events
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// Bot is ready
|
|
33
|
+
client.on('ready', () => {
|
|
34
|
+
console.log('Bot is ready!');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// New message received
|
|
38
|
+
client.on('message', (message: Message) => {
|
|
39
|
+
// Handle message
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Message edited
|
|
43
|
+
client.on('messageUpdate', (oldMessage: Message | null, newMessage: Message) => {
|
|
44
|
+
// Handle edit
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Message deleted
|
|
48
|
+
client.on('messageDelete', (message: Message) => {
|
|
49
|
+
// Handle deletion
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Error occurred
|
|
53
|
+
client.on('error', (error: Error) => {
|
|
54
|
+
console.error('Error:', error);
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Guild Events
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Bot joined a server
|
|
62
|
+
client.on('guildCreate', (guild: Guild) => {});
|
|
63
|
+
|
|
64
|
+
// Server updated
|
|
65
|
+
client.on('guildUpdate', (oldGuild: Guild | null, newGuild: Guild) => {});
|
|
66
|
+
|
|
67
|
+
// Bot left a server
|
|
68
|
+
client.on('guildDelete', (guild: Guild) => {});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Member Events
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// Member joined
|
|
75
|
+
client.on('guildMemberAdd', (member: GuildMember) => {});
|
|
76
|
+
|
|
77
|
+
// Member left
|
|
78
|
+
client.on('guildMemberRemove', (member: GuildMember) => {});
|
|
79
|
+
|
|
80
|
+
// Member updated
|
|
81
|
+
client.on('guildMemberUpdate', (oldMember: GuildMember | null, newMember: GuildMember) => {});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Channel Events
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// Channel created
|
|
88
|
+
client.on('channelCreate', (channel: Channel) => {});
|
|
89
|
+
|
|
90
|
+
// Channel updated
|
|
91
|
+
client.on('channelUpdate', (oldChannel: Channel | null, newChannel: Channel) => {});
|
|
92
|
+
|
|
93
|
+
// Channel deleted
|
|
94
|
+
client.on('channelDelete', (channel: Channel) => {});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 💬 Sending Messages
|
|
98
|
+
|
|
99
|
+
### Simple Text Message
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
await client.sendMessage(channelId, 'Hello, world!');
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Rich Message with Embed
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
await client.sendMessage(channelId, {
|
|
109
|
+
content: 'Optional text content',
|
|
110
|
+
embeds: [{
|
|
111
|
+
title: 'Embed Title',
|
|
112
|
+
description: 'Embed description',
|
|
113
|
+
color: '#00ff00', // or 0x00ff00
|
|
114
|
+
fields: [
|
|
115
|
+
{ name: 'Field 1', value: 'Value 1', inline: true },
|
|
116
|
+
{ name: 'Field 2', value: 'Value 2', inline: true }
|
|
117
|
+
],
|
|
118
|
+
footer: {
|
|
119
|
+
text: 'Footer text',
|
|
120
|
+
iconUrl: 'https://example.com/icon.png'
|
|
121
|
+
},
|
|
122
|
+
thumbnail: {
|
|
123
|
+
url: 'https://example.com/thumb.png'
|
|
124
|
+
},
|
|
125
|
+
image: {
|
|
126
|
+
url: 'https://example.com/image.png'
|
|
127
|
+
},
|
|
128
|
+
author: {
|
|
129
|
+
name: 'Author Name',
|
|
130
|
+
iconUrl: 'https://example.com/avatar.png',
|
|
131
|
+
url: 'https://example.com'
|
|
132
|
+
},
|
|
133
|
+
timestamp: new Date()
|
|
134
|
+
}]
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## ✏️ Message Operations
|
|
139
|
+
|
|
140
|
+
### Reply to a Message
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
client.on('message', async (message) => {
|
|
144
|
+
// Simple reply
|
|
145
|
+
await message.reply('This is a reply');
|
|
146
|
+
|
|
147
|
+
// Reply with embed
|
|
148
|
+
await message.reply({
|
|
149
|
+
embeds: [{
|
|
150
|
+
title: 'Reply',
|
|
151
|
+
description: 'This is a rich reply'
|
|
152
|
+
}]
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Edit a Message
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
const sentMessage = await client.sendMessage(channelId, 'Original');
|
|
161
|
+
await sentMessage.edit('Edited content');
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Delete a Message
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
await message.delete();
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### React to a Message
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
await message.react('👍');
|
|
174
|
+
await message.react('❤️');
|
|
175
|
+
await message.react('🎉');
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 👤 User Operations
|
|
179
|
+
|
|
180
|
+
### Get User Information
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const user = await client.getUser(userId);
|
|
184
|
+
|
|
185
|
+
console.log(user.id); // string
|
|
186
|
+
console.log(user.username); // string
|
|
187
|
+
console.log(user.displayName); // string
|
|
188
|
+
console.log(user.avatarUrl); // string | undefined
|
|
189
|
+
console.log(user.bot); // boolean
|
|
190
|
+
console.log(user.platform); // string
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Access Message Author
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
client.on('message', (message) => {
|
|
197
|
+
const author = message.author;
|
|
198
|
+
console.log(`Message from ${author.username}`);
|
|
199
|
+
|
|
200
|
+
if (author.bot) {
|
|
201
|
+
return; // Ignore bot messages
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## 📺 Channel Operations
|
|
207
|
+
|
|
208
|
+
### Get Channel Information
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
const channel = await client.getChannel(channelId);
|
|
212
|
+
|
|
213
|
+
console.log(channel.id); // string
|
|
214
|
+
console.log(channel.name); // string
|
|
215
|
+
console.log(channel.type); // 'text' | 'voice' | 'dm' | 'group' | etc.
|
|
216
|
+
console.log(channel.topic); // string | undefined
|
|
217
|
+
console.log(channel.platform); // string
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Access Message Channel
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
client.on('message', (message) => {
|
|
224
|
+
console.log(`Message in ${message.channel.name}`);
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## 🏰 Guild Operations
|
|
229
|
+
|
|
230
|
+
### Get Guild Information
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
const guild = await client.getGuild(guildId);
|
|
234
|
+
|
|
235
|
+
console.log(guild.id); // string
|
|
236
|
+
console.log(guild.name); // string
|
|
237
|
+
console.log(guild.iconUrl); // string | undefined
|
|
238
|
+
console.log(guild.memberCount); // number | undefined
|
|
239
|
+
console.log(guild.description); // string | undefined
|
|
240
|
+
console.log(guild.ownerId); // string | undefined
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Access Message Guild
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
client.on('message', async (message) => {
|
|
247
|
+
if (message.guild) {
|
|
248
|
+
const guild = await client.getGuild(message.guild.id);
|
|
249
|
+
console.log(`Message in ${guild.name}`);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## 🎨 Embed Builder Pattern
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
const embed: Embed = {
|
|
258
|
+
title: 'Title',
|
|
259
|
+
description: 'Description',
|
|
260
|
+
url: 'https://example.com',
|
|
261
|
+
color: '#5865F2', // Discord blurple
|
|
262
|
+
|
|
263
|
+
fields: [
|
|
264
|
+
{
|
|
265
|
+
name: 'Field Name',
|
|
266
|
+
value: 'Field Value',
|
|
267
|
+
inline: true
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
|
|
271
|
+
footer: {
|
|
272
|
+
text: 'Footer text',
|
|
273
|
+
iconUrl: 'https://example.com/footer.png'
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
thumbnail: {
|
|
277
|
+
url: 'https://example.com/thumb.png'
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
image: {
|
|
281
|
+
url: 'https://example.com/image.png'
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
author: {
|
|
285
|
+
name: 'Author Name',
|
|
286
|
+
iconUrl: 'https://example.com/avatar.png',
|
|
287
|
+
url: 'https://example.com'
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
timestamp: new Date()
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
await client.sendMessage(channelId, { embeds: [embed] });
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## 🔧 Client Configuration
|
|
297
|
+
|
|
298
|
+
### Discord-Specific Configuration
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
import { GatewayIntentBits } from 'discord.js';
|
|
302
|
+
|
|
303
|
+
const client = new UnifiedClient({
|
|
304
|
+
platform: 'discord',
|
|
305
|
+
config: {
|
|
306
|
+
token: 'YOUR_TOKEN',
|
|
307
|
+
intents: [
|
|
308
|
+
GatewayIntentBits.Guilds,
|
|
309
|
+
GatewayIntentBits.GuildMessages,
|
|
310
|
+
GatewayIntentBits.MessageContent,
|
|
311
|
+
GatewayIntentBits.GuildMembers
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Root-Specific Configuration
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
const client = new UnifiedClient({
|
|
321
|
+
platform: 'root',
|
|
322
|
+
config: {
|
|
323
|
+
token: 'YOUR_TOKEN',
|
|
324
|
+
appId: 'YOUR_APP_ID' // if required
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## 🎯 Client Properties
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
client.platformName // 'discord' | 'root'
|
|
333
|
+
client.platformVersion // string
|
|
334
|
+
client.isConnected // boolean
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## 🎭 Client Methods
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
// Connection
|
|
341
|
+
await client.connect()
|
|
342
|
+
await client.disconnect()
|
|
343
|
+
|
|
344
|
+
// Messaging
|
|
345
|
+
await client.sendMessage(channelId, content)
|
|
346
|
+
await client.editMessage(messageId, channelId, newContent)
|
|
347
|
+
await client.deleteMessage(messageId, channelId)
|
|
348
|
+
|
|
349
|
+
// Resources
|
|
350
|
+
await client.getUser(userId)
|
|
351
|
+
await client.getChannel(channelId)
|
|
352
|
+
await client.getGuild(guildId)
|
|
353
|
+
|
|
354
|
+
// Utility
|
|
355
|
+
client.setLogLevel(LogLevel.DEBUG)
|
|
356
|
+
const provider = client.getProvider()
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## ⚠️ Error Handling
|
|
360
|
+
|
|
361
|
+
### Using Try-Catch
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
try {
|
|
365
|
+
await client.sendMessage(channelId, 'Hello!');
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (error instanceof MessageError) {
|
|
368
|
+
console.error('Failed to send message');
|
|
369
|
+
} else if (error instanceof ChannelError) {
|
|
370
|
+
console.error('Invalid channel');
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Error Event Listener
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
client.on('error', (error: Error) => {
|
|
379
|
+
console.error('Error:', error.message);
|
|
380
|
+
|
|
381
|
+
if (error instanceof BridgeError) {
|
|
382
|
+
// Handle bridge-specific errors
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Available Error Classes
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
import {
|
|
391
|
+
BridgeError,
|
|
392
|
+
UnsupportedPlatformError,
|
|
393
|
+
UnsupportedFeatureError,
|
|
394
|
+
AuthenticationError,
|
|
395
|
+
ResourceNotFoundError,
|
|
396
|
+
ChannelError,
|
|
397
|
+
MessageError,
|
|
398
|
+
PermissionError,
|
|
399
|
+
RateLimitError,
|
|
400
|
+
ConnectionError,
|
|
401
|
+
ConfigurationError
|
|
402
|
+
} from 'Library@DR-Conversion';
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## 🪵 Logging
|
|
406
|
+
|
|
407
|
+
### Setting Log Level
|
|
408
|
+
|
|
409
|
+
```typescript
|
|
410
|
+
import { LogLevel } from 'Library.DR-Conversion';
|
|
411
|
+
|
|
412
|
+
// In constructor
|
|
413
|
+
const client = new UnifiedClient({
|
|
414
|
+
platform: 'discord',
|
|
415
|
+
config: { token: 'TOKEN' },
|
|
416
|
+
logLevel: LogLevel.DEBUG
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// At runtime
|
|
420
|
+
client.setLogLevel(LogLevel.INFO);
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Log Levels
|
|
424
|
+
|
|
425
|
+
- `LogLevel.NONE` - No logging
|
|
426
|
+
- `LogLevel.ERROR` - Only errors
|
|
427
|
+
- `LogLevel.WARN` - Warnings and errors
|
|
428
|
+
- `LogLevel.INFO` - General information (default)
|
|
429
|
+
- `LogLevel.DEBUG` - Detailed debug information
|
|
430
|
+
|
|
431
|
+
## 🎪 Advanced Usage
|
|
432
|
+
|
|
433
|
+
### Accessing Platform-Specific Client
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
import { DiscordProvider } from 'Library.DR-Conversion';
|
|
437
|
+
|
|
438
|
+
const provider = client.getProvider() as DiscordProvider;
|
|
439
|
+
const discordClient = provider.getClient();
|
|
440
|
+
|
|
441
|
+
// Now use discord.js specific features
|
|
442
|
+
discordClient.on('voiceStateUpdate', (oldState, newState) => {
|
|
443
|
+
// Discord-specific event
|
|
444
|
+
});
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### Environment-Based Platform Selection
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
const client = new UnifiedClient({
|
|
451
|
+
platform: process.env.PLATFORM as 'discord' | 'root',
|
|
452
|
+
config: {
|
|
453
|
+
token: process.env.BOT_TOKEN!
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
## 🔍 Type Definitions
|
|
459
|
+
|
|
460
|
+
### Message
|
|
461
|
+
|
|
462
|
+
```typescript
|
|
463
|
+
interface Message {
|
|
464
|
+
id: string;
|
|
465
|
+
content: string;
|
|
466
|
+
author: User;
|
|
467
|
+
channel: Channel;
|
|
468
|
+
timestamp: Date;
|
|
469
|
+
platform: string;
|
|
470
|
+
guild?: Guild;
|
|
471
|
+
embeds?: Embed[];
|
|
472
|
+
attachments?: Attachment[];
|
|
473
|
+
mentionsEveryone?: boolean;
|
|
474
|
+
mentions?: User[];
|
|
475
|
+
|
|
476
|
+
reply(content: string | MessageOptions): Promise<Message>;
|
|
477
|
+
delete(): Promise<void>;
|
|
478
|
+
edit(content: string): Promise<Message>;
|
|
479
|
+
react(emoji: string): Promise<void>;
|
|
480
|
+
}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### User
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
interface User {
|
|
487
|
+
id: string;
|
|
488
|
+
username: string;
|
|
489
|
+
displayName: string;
|
|
490
|
+
avatarUrl?: string;
|
|
491
|
+
bot: boolean;
|
|
492
|
+
platform: string;
|
|
493
|
+
discriminator?: string;
|
|
494
|
+
isCurrentUser?: boolean;
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Channel
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
interface Channel {
|
|
502
|
+
id: string;
|
|
503
|
+
name: string;
|
|
504
|
+
type: ChannelType;
|
|
505
|
+
platform: string;
|
|
506
|
+
topic?: string;
|
|
507
|
+
nsfw?: boolean;
|
|
508
|
+
parentId?: string;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
type ChannelType = 'text' | 'voice' | 'dm' | 'group' | 'category' | 'announcement' | 'thread';
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### Guild
|
|
515
|
+
|
|
516
|
+
```typescript
|
|
517
|
+
interface Guild {
|
|
518
|
+
id: string;
|
|
519
|
+
name: string;
|
|
520
|
+
iconUrl?: string;
|
|
521
|
+
memberCount?: number;
|
|
522
|
+
platform: string;
|
|
523
|
+
description?: string;
|
|
524
|
+
ownerId?: string;
|
|
525
|
+
features?: string[];
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
## 📋 Common Patterns
|
|
530
|
+
|
|
531
|
+
### Command Handler
|
|
532
|
+
|
|
533
|
+
```typescript
|
|
534
|
+
const PREFIX = '!';
|
|
535
|
+
|
|
536
|
+
client.on('message', async (message) => {
|
|
537
|
+
if (message.author.bot) return;
|
|
538
|
+
if (!message.content.startsWith(PREFIX)) return;
|
|
539
|
+
|
|
540
|
+
const args = message.content.slice(PREFIX.length).trim().split(/\s+/);
|
|
541
|
+
const command = args.shift()?.toLowerCase();
|
|
542
|
+
|
|
543
|
+
switch (command) {
|
|
544
|
+
case 'ping':
|
|
545
|
+
await message.reply('Pong!');
|
|
546
|
+
break;
|
|
547
|
+
|
|
548
|
+
case 'help':
|
|
549
|
+
await message.reply({
|
|
550
|
+
embeds: [{
|
|
551
|
+
title: 'Help',
|
|
552
|
+
description: 'Available commands...'
|
|
553
|
+
}]
|
|
554
|
+
});
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
### Graceful Shutdown
|
|
561
|
+
|
|
562
|
+
```typescript
|
|
563
|
+
process.on('SIGINT', async () => {
|
|
564
|
+
console.log('Shutting down...');
|
|
565
|
+
await client.disconnect();
|
|
566
|
+
process.exit(0);
|
|
567
|
+
});
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### Rate Limiting
|
|
571
|
+
|
|
572
|
+
```typescript
|
|
573
|
+
const cooldowns = new Map();
|
|
574
|
+
|
|
575
|
+
client.on('message', async (message) => {
|
|
576
|
+
const userId = message.author.id;
|
|
577
|
+
|
|
578
|
+
if (cooldowns.has(userId)) {
|
|
579
|
+
await message.reply('Please wait before using this command again');
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
cooldowns.set(userId, Date.now());
|
|
584
|
+
setTimeout(() => cooldowns.delete(userId), 5000);
|
|
585
|
+
|
|
586
|
+
// Handle command
|
|
587
|
+
});
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
---
|
|
591
|
+
|
|
592
|
+
For more detailed documentation, see [README.md](README.md) and [IMPLEMENTATION.md](IMPLEMENTATION.md).
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-02-15
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of Library.DR-Conversion v0.1.0
|
|
12
|
+
- UnifiedClient for platform-agnostic bot development
|
|
13
|
+
- Full Discord support via discord.js integration
|
|
14
|
+
- Root platform provider stub (ready for implementation)
|
|
15
|
+
- Comprehensive type system with generic interfaces
|
|
16
|
+
- BaseProvider abstract class for easy platform extensions
|
|
17
|
+
- Support for rich embeds across platforms
|
|
18
|
+
- Message, User, Channel, and Guild operations
|
|
19
|
+
- Event system for all platform events
|
|
20
|
+
- Custom error classes for better error handling
|
|
21
|
+
- Logger utility with configurable log levels
|
|
22
|
+
- Four example bots demonstrating various features:
|
|
23
|
+
- simple-bot: Basic cross-platform bot
|
|
24
|
+
- discord-bot: Discord-specific features
|
|
25
|
+
- root-bot: Root platform example
|
|
26
|
+
- advanced-bot: Advanced features and patterns
|
|
27
|
+
- Complete TypeScript support with strict mode
|
|
28
|
+
- Comprehensive JSDoc documentation
|
|
29
|
+
- MIT License
|
|
30
|
+
- Contributing guidelines
|
|
31
|
+
- Example environment configuration
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
#### Core
|
|
36
|
+
- UnifiedClient with platform switching
|
|
37
|
+
- Type-safe event handling
|
|
38
|
+
- Async/await based API
|
|
39
|
+
- Platform provider system
|
|
40
|
+
|
|
41
|
+
#### Discord
|
|
42
|
+
- Full message support (send, edit, delete)
|
|
43
|
+
- Rich embeds with all Discord features
|
|
44
|
+
- Reactions support
|
|
45
|
+
- User, channel, and guild fetching
|
|
46
|
+
- Guild member events
|
|
47
|
+
- Message update/delete events
|
|
48
|
+
- Typing indicators
|
|
49
|
+
- Error handling and reconnection
|
|
50
|
+
|
|
51
|
+
#### Root
|
|
52
|
+
- Stub implementation ready for completion
|
|
53
|
+
- Type definitions for Root entities
|
|
54
|
+
- Converter structure in place
|
|
55
|
+
- Example bot template
|
|
56
|
+
|
|
57
|
+
#### Developer Experience
|
|
58
|
+
- Full TypeScript definitions
|
|
59
|
+
- IntelliSense support
|
|
60
|
+
- Configurable logging
|
|
61
|
+
- Detailed error messages
|
|
62
|
+
- Extensive examples
|
|
63
|
+
|
|
64
|
+
### Documentation
|
|
65
|
+
- Comprehensive README with quick start
|
|
66
|
+
- API reference
|
|
67
|
+
- Architecture overview
|
|
68
|
+
- Contribution guidelines
|
|
69
|
+
- Multiple working examples
|
|
70
|
+
- JSDoc comments throughout
|
|
71
|
+
|
|
72
|
+
### Platform Support
|
|
73
|
+
- ✅ Discord (Fully Supported)
|
|
74
|
+
- 🚧 Root (Stub Implementation)
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## [Unreleased]
|
|
79
|
+
|
|
80
|
+
### Planned
|
|
81
|
+
- Complete Root platform implementation
|
|
82
|
+
- Slack platform support
|
|
83
|
+
- Telegram platform support
|
|
84
|
+
- Comprehensive test suite
|
|
85
|
+
- Button and select menu components
|
|
86
|
+
- File upload support
|
|
87
|
+
- Voice channel support
|
|
88
|
+
- Slash command helpers
|
|
89
|
+
- Rate limiting utilities
|
|
90
|
+
- Message caching
|
|
91
|
+
- Webhook support
|
|
92
|
+
- Interactive CLI for bot scaffolding
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
[1.0.0]: https://github.com/Shadowcrushers/chat-platform-bridge/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shadowcrushers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|