dc-cloud 0.0.1

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 ADDED
@@ -0,0 +1,1086 @@
1
+ # DCloud 🌥️
2
+
3
+ <div align="center">
4
+
5
+ [![Version](https://img.shields.io/badge/version-0.0.1-blue?style=flat-square)](https://github.com/NeelFrostrain/DCloud)
6
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen?style=flat-square)](https://nodejs.org)
7
+ [![License](https://img.shields.io/badge/license-private-red?style=flat-square)](LICENSE)
8
+ [![TypeScript](https://img.shields.io/badge/typescript-%3E%3D5.0-blue?style=flat-square)](https://www.typescriptlang.org)
9
+
10
+ **Discord-Based Cloud Storage Solution**
11
+
12
+ Transform your Discord server into a secure cloud storage backend with automatic compression, segmentation, and intelligent file management.
13
+
14
+ [**Documentation**](#-table-of-contents) • [**Quick Start**](#-quick-start) • [**Examples**](#-example-workflow) • [**API Docs**](#-api-documentation)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## 📋 Table of Contents
21
+
22
+ - [Overview](#-overview)
23
+ - [Quick Start](#-quick-start)
24
+ - [Features](#-features)
25
+ - [Prerequisites](#-prerequisites)
26
+ - [Installation](#-installation)
27
+ - [Configuration](#-configuration)
28
+ - [Usage](#-usage)
29
+ - [API Documentation](#-api-documentation)
30
+ - [Project Structure](#-project-structure)
31
+ - [Scripts & Commands](#-scripts--commands)
32
+ - [Troubleshooting](#-troubleshooting)
33
+ - [Development](#-development)
34
+ - [FAQ](#-faq)
35
+
36
+ ---
37
+
38
+ ## 🎯 Overview
39
+
40
+ **DCloud** is an innovative cloud storage solution that leverages Discord servers as a secure backend for file storage. It automatically compresses files into 8MB segments using 7-Zip (LZMA2), uploads them to Discord forum channels via a dedicated bot, and maintains metadata for easy retrieval and restoration.
41
+
42
+ ### 🔄 How It Works
43
+
44
+ ```
45
+ Local File/Folder
46
+
47
+ Compression (LZMA2)
48
+
49
+ Segmentation (8MB chunks)
50
+
51
+ Upload to Discord Bot
52
+
53
+ Store in Forum Threads
54
+
55
+ Metadata Tracking (JSON)
56
+ ```
57
+
58
+ ### 💡 Key Concept
59
+
60
+ DCloud acts as a bridge between your local file system and Discord servers, enabling:
61
+
62
+ - **🗜️ Compression**: Automatic file/folder compression using LZMA2 algorithm with 512MB dictionary
63
+ - **✂️ Segmentation**: Intelligent splitting of large files into manageable 8MB parts
64
+ - **📤 Upload**: Fully automated uploading to Discord forum threads via bot
65
+ - **📥 Retrieval**: Seamless download and restore with automatic cleanup
66
+ - **📋 Metadata**: JSON-based tracking for file integrity and recovery
67
+
68
+ ---
69
+
70
+ ## ⚡ Quick Start
71
+
72
+ ### 1️⃣ Install Package
73
+
74
+ ```bash
75
+ npm install dc-cloud
76
+ ```
77
+
78
+ ### 2️⃣ Clone & Install (Development)
79
+
80
+ ```bash
81
+ git clone https://github.com/NeelFrostrain/DCloud.git
82
+ cd DCloud
83
+ npm install
84
+ ```
85
+
86
+ ### 3️⃣ Get Discord Credentials
87
+
88
+ - Create a Discord bot at [Discord Developer Portal](https://discord.com/developers/applications)
89
+ - Get your bot token, server ID, and forum channel ID
90
+ - Add bot to your server with proper permissions
91
+
92
+ ### 4️⃣ Update Configuration
93
+
94
+ Edit `src/index.ts`:
95
+
96
+ ```typescript
97
+ const TOKEN = "YOUR_BOT_TOKEN";
98
+ const CHANNEL_ID = "YOUR_FORUM_CHANNEL_ID";
99
+ const GUILD_ID = "YOUR_SERVER_ID";
100
+ ```
101
+
102
+ ### 5️⃣ Run
103
+
104
+ ```bash
105
+ # Development mode (with auto-reload)
106
+ npm run dev
107
+
108
+ # Or production mode
109
+ npm run build && npm start
110
+ ```
111
+
112
+ ---
113
+
114
+ ## ✨ Features
115
+
116
+ | Feature | Description |
117
+ | ------------------------------ | ------------------------------------------------------------- |
118
+ | **🗜️ Advanced Compression** | LZMA2 algorithm with 512MB dictionary for maximum compression |
119
+ | **✂️ Smart Segmentation** | Automatic 8MB chunking for Discord compatibility |
120
+ | **🤖 Discord Bot Integration** | Full Discord.js v14 support with forum thread management |
121
+ | **📋 Metadata Tracking** | JSON-based metadata for file integrity and recovery |
122
+ | **⚡ Concurrent Uploads** | Parallel upload handling for optimal performance |
123
+ | **📥 Full Restoration** | Complete download and extraction pipeline |
124
+ | **✅ TypeScript** | Fully typed codebase with strict type checking |
125
+ | **🎨 Rich Logging** | Color-coded console output with Chalk |
126
+ | **🛡️ Error Handling** | Comprehensive error management and recovery |
127
+ | **📦 Production Ready** | Optimized for production use with proper cleanup |
128
+
129
+ ---
130
+
131
+ ## 📦 Prerequisites
132
+
133
+ ### Minimum Requirements
134
+
135
+ | Requirement | Version | Note |
136
+ | -------------- | ----------- | ------------------------------------------ |
137
+ | **Node.js** | ≥ 18.0.0 | Runtime environment |
138
+ | **npm** | ≥ 9.0.0 | Package manager |
139
+ | **TypeScript** | ≥ 5.0 | Peer dependency (required for development) |
140
+ | **Disk Space** | 500MB+ | For temporary files during compression |
141
+ | **RAM** | 2GB minimum | 4GB+ recommended |
142
+
143
+ ### External Dependencies
144
+
145
+ - **Discord Server**: Admin access to create forum channels
146
+ - **Discord Bot**: Valid bot token with proper permissions
147
+ - **7-Zip**: Bundled via `7zip-bin` package (auto-installed)
148
+
149
+ ### Discord Bot Permissions
150
+
151
+ Your bot requires these permissions:
152
+
153
+ ```
154
+ PERMISSIONS NEEDED:
155
+ ✓ Send Messages
156
+ ✓ Create Public Threads
157
+ ✓ Send Messages in Threads
158
+ ✓ Embed Links
159
+ ✓ Attach Files
160
+ ✓ Read Message History
161
+ ```
162
+
163
+ ### Operating System Support
164
+
165
+ | OS | Status | Notes |
166
+ | ----------- | ------------------ | ------------------------------------------ |
167
+ | **Windows** | ✅ Fully Supported | Recommended |
168
+ | **macOS** | ✅ Fully Supported | Requires p7zip-full |
169
+ | **Linux** | ✅ Fully Supported | Install: `sudo apt-get install p7zip-full` |
170
+
171
+ ---
172
+
173
+ ## 🚀 Installation
174
+
175
+ ### Step 1: Clone Repository
176
+
177
+ ```bash
178
+ git clone https://github.com/NeelFrostrain/DCloud.git
179
+ cd DCloud
180
+ ```
181
+
182
+ ### Step 2: Install Dependencies
183
+
184
+ ```bash
185
+ npm install
186
+ ```
187
+
188
+ This installs:
189
+
190
+ - **discord.js** v14.25.1 - Discord bot framework
191
+ - **7zip-bin** v5.2.0 - 7-Zip binary
192
+ - **chalk** v5.6.2 - Terminal styling
193
+ - **Dev Tools** - ESLint, TypeScript, Nodemon
194
+
195
+ ### Step 3: Verify Installation
196
+
197
+ ```bash
198
+ # Check TypeScript compilation
199
+ npm run type-check
200
+
201
+ # Lint code
202
+ npm run lint
203
+
204
+ # Try building
205
+ npm run build
206
+ ```
207
+
208
+ ### Step 4: Configuration (See [Configuration](#-configuration) Section)
209
+
210
+ ---
211
+
212
+ ## ⚙️ Configuration
213
+
214
+ ### Setting Up Discord Bot (Step-by-Step)
215
+
216
+ #### 1. Create Discord Application
217
+
218
+ 1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
219
+ 2. Click **"New Application"**
220
+ 3. Enter name: `DCloud Bot` (or your preference)
221
+ 4. Accept Terms and Create
222
+
223
+ #### 2. Create Bot User
224
+
225
+ 1. Navigate to **"Bot"** section
226
+ 2. Click **"Add Bot"**
227
+ 3. Click **"Reset Token"** to copy bot token
228
+ 4. **⚠️ Keep this token secret!** Never commit to git
229
+
230
+ #### 3. Configure Bot Permissions
231
+
232
+ 1. Go to **"OAuth2"** → **"URL Generator"**
233
+ 2. Select **Scopes**: `bot`
234
+ 3. Select **Permissions**:
235
+ - ✓ Send Messages
236
+ - ✓ Create Public Threads
237
+ - ✓ Send Messages in Threads
238
+ - ✓ Embed Links
239
+ - ✓ Attach Files
240
+ - ✓ Read Message History
241
+ 4. Copy the generated URL
242
+
243
+ #### 4. Add Bot to Server
244
+
245
+ 1. Open the OAuth2 URL in your browser
246
+ 2. Select your Discord server
247
+ 3. Click **"Authorize"**
248
+ 4. Complete the CAPTCHA
249
+
250
+ #### 5. Get Required IDs
251
+
252
+ **Method 1: Developer Mode** (Easiest)
253
+
254
+ 1. Open Discord User Settings → Advanced
255
+ 2. Enable **"Developer Mode"**
256
+ 3. Right-click server name → **"Copy Server ID"** (Server ID)
257
+ 4. Right-click forum channel → **"Copy Channel ID"** (Forum Channel ID)
258
+
259
+ **Method 2: Discord API**
260
+ Use [Discord Server Info Bot](https://top.gg/bot/905182607851741205) or similar
261
+
262
+ ### Environment Configuration
263
+
264
+ #### Option A: Direct in Code (Development)
265
+
266
+ Edit `src/index.ts`:
267
+
268
+ ```typescript
269
+ import { DCloud } from "./classes/dCloud";
270
+
271
+ const TOKEN = "MTQxODYyMjg0MDE4NTQyMTgzNg..."; // Bot token
272
+ const CHANNEL_ID = "1465235994243502162"; // Forum channel ID
273
+ const GUILD_ID = "1316439358609297418"; // Server ID
274
+
275
+ const dCloud = DCloud({
276
+ FORUM_CHANNEL_ID: CHANNEL_ID,
277
+ TOKEN: TOKEN,
278
+ SERVER_ID: GUILD_ID,
279
+ });
280
+
281
+ await dCloud.init();
282
+ ```
283
+
284
+ #### Option B: Environment Variables (Production)
285
+
286
+ Create `.env` file:
287
+
288
+ ```bash
289
+ DISCORD_TOKEN=YOUR_BOT_TOKEN
290
+ DISCORD_SERVER_ID=YOUR_SERVER_ID
291
+ DISCORD_FORUM_CHANNEL_ID=YOUR_FORUM_CHANNEL_ID
292
+ ```
293
+
294
+ Update `src/index.ts`:
295
+
296
+ ```typescript
297
+ import dotenv from "dotenv";
298
+ dotenv.config();
299
+
300
+ const dCloud = DCloud({
301
+ TOKEN: process.env.DISCORD_TOKEN!,
302
+ SERVER_ID: process.env.DISCORD_SERVER_ID!,
303
+ FORUM_CHANNEL_ID: process.env.DISCORD_FORUM_CHANNEL_ID!,
304
+ });
305
+ ```
306
+
307
+ ### Configuration Verification
308
+
309
+ Test your configuration:
310
+
311
+ ```bash
312
+ npm run dev
313
+ ```
314
+
315
+ Expected output:
316
+
317
+ ```
318
+ [Bot] [Status]: Logged in as DCloud#1234
319
+ [Bot] [Guild]: Connected to Server: MyServer
320
+ [Bot] [Channel]: Target Forum: #uploads
321
+ ```
322
+
323
+ If you see errors, review the [Troubleshooting](#-troubleshooting) section.
324
+
325
+ ---
326
+
327
+ ## 📖 Usage
328
+
329
+ ### Using from NPM Package
330
+
331
+ ```typescript
332
+ import { DCloud } from "@discord/dcloud";
333
+
334
+ const dCloud = DCloud({
335
+ FORUM_CHANNEL_ID: "1465235994243502162",
336
+ TOKEN: "YOUR_BOT_TOKEN",
337
+ SERVER_ID: "1316439358609297418",
338
+ });
339
+
340
+ // Initialize the bot
341
+ await dCloud.init();
342
+
343
+ // Upload a file
344
+ const result = await dCloud.upload("C:\\path\\to\\file.zip");
345
+ console.log("Upload complete:", result);
346
+ ```
347
+
348
+ ### Local Development Setup
349
+
350
+ ```typescript
351
+ import { DCloud } from "./src/classes/dCloud";
352
+
353
+ const dCloud = DCloud({
354
+ FORUM_CHANNEL_ID: "1465235994243502162",
355
+ TOKEN: "YOUR_BOT_TOKEN",
356
+ SERVER_ID: "1316439358609297418",
357
+ });
358
+
359
+ // Initialize the bot
360
+ await dCloud.init();
361
+
362
+ // Upload a file
363
+ const result = await dCloud.upload("C:\\path\\to\\file.zip");
364
+ console.log("Upload complete:", result);
365
+ ```
366
+
367
+ ```typescript
368
+ // Download using metadata URL
369
+ await dCloud.downloader(
370
+ "https://cdn.discordapp.com/attachments/.../metadata.json",
371
+ "C:\\output\\path",
372
+ );
373
+ console.log("Download and extraction complete!");
374
+ ```
375
+
376
+ ### Running the Application
377
+
378
+ #### 1. Development Mode (Auto-reload)
379
+
380
+ ```bash
381
+ npm run dev
382
+ ```
383
+
384
+ Watches for file changes and automatically restarts.
385
+
386
+ #### 2. Production Mode (Compiled)
387
+
388
+ ```bash
389
+ npm run build
390
+ npm start
391
+ ```
392
+
393
+ Compiles TypeScript to JavaScript and runs it.
394
+
395
+ #### 3. Type Check Only
396
+
397
+ ```bash
398
+ npm run type-check
399
+ ```
400
+
401
+ Validates TypeScript without emitting files.
402
+
403
+ ---
404
+
405
+ ## 🔌 API Documentation
406
+
407
+ ### DCloud Class
408
+
409
+ Main class for file upload/download operations.
410
+
411
+ #### Constructor
412
+
413
+ ```typescript
414
+ DCloud(config: ICloudBot): DCloudClass
415
+ ```
416
+
417
+ **Parameters**:
418
+
419
+ - `config.TOKEN`: Discord bot token (string)
420
+ - `config.SERVER_ID`: Discord guild/server ID (string)
421
+ - `config.FORUM_CHANNEL_ID`: Target forum channel ID (string)
422
+
423
+ #### Methods
424
+
425
+ ##### `init(): Promise<void>`
426
+
427
+ Initializes the bot and connects to Discord.
428
+
429
+ ```typescript
430
+ await dCloud.init();
431
+ ```
432
+
433
+ ##### `upload(filePath: string): Promise<ICompressorResult>`
434
+
435
+ Uploads a file or directory to Discord.
436
+
437
+ **Parameters**:
438
+
439
+ - `filePath`: Absolute path to file or directory
440
+
441
+ **Returns**: Upload result with metadata URL
442
+
443
+ **Example**:
444
+
445
+ ```typescript
446
+ const result = await dCloud.upload("C:\\files\\mydata.zip");
447
+ ```
448
+
449
+ **Process Flow**:
450
+
451
+ 1. Validates input path
452
+ 2. Initializes Discord thread with file info
453
+ 3. Compresses file with LZMA2 (8MB segments)
454
+ 4. Uploads segments to Discord
455
+ 5. Generates and uploads metadata.json
456
+ 6. Cleans up temporary files
457
+ 7. Returns metadata URL
458
+
459
+ ##### `downloader(metadataUrl: string, outputPath: string): Promise<void>`
460
+
461
+ Downloads and restores files from Discord.
462
+
463
+ **Parameters**:
464
+
465
+ - `metadataUrl`: URL to metadata.json file
466
+ - `outputPath`: Directory to save restored files
467
+
468
+ **Example**:
469
+
470
+ ```typescript
471
+ await dCloud.downloader(
472
+ "https://cdn.discordapp.com/attachments/.../metadata.json",
473
+ "C:\\restored\\",
474
+ );
475
+ ```
476
+
477
+ **Process Flow**:
478
+
479
+ 1. Fetches metadata.json
480
+ 2. Creates directory structure
481
+ 3. Downloads all archive segments
482
+ 4. Extracts using 7-Zip
483
+ 5. Cleans up temporary files
484
+ 6. Completes restoration
485
+
486
+ ### CloudBot Class
487
+
488
+ Handles Discord bot operations and thread management.
489
+
490
+ #### Methods
491
+
492
+ ##### `Init(): Promise<void>`
493
+
494
+ Initializes the Discord bot connection.
495
+
496
+ ##### `IsBotOnline(): boolean`
497
+
498
+ Checks if bot is connected and ready.
499
+
500
+ ### Interfaces
501
+
502
+ #### ICloudBot
503
+
504
+ ```typescript
505
+ interface ICloudBot {
506
+ TOKEN: string; // Discord bot token
507
+ SERVER_ID: string; // Guild/server ID
508
+ FORUM_CHANNEL_ID: string; // Forum channel ID
509
+ }
510
+ ```
511
+
512
+ #### ICompressor
513
+
514
+ ```typescript
515
+ interface ICompressor {
516
+ originalName: string; // Original file/folder name
517
+ totalSize: string; // Size in MB
518
+ createdAt: string; // Creation timestamp
519
+ parts: {
520
+ name: string; // Segment filename
521
+ url: string; // Discord CDN URL
522
+ }[];
523
+ }
524
+ ```
525
+
526
+ #### ICompressorResult
527
+
528
+ ```typescript
529
+ interface ICompressorResult {
530
+ originalName: string; // Original file/folder name
531
+ totalSize: string; // Total size in MB
532
+ createdAt: string; // Creation timestamp
533
+ metadata: string; // Metadata.json URL
534
+ }
535
+ ```
536
+
537
+ ---
538
+
539
+ ## 📁 Project Structure
540
+
541
+ ```
542
+ DCloud/
543
+ ├── src/
544
+ │ ├── classes/
545
+ │ │ ├── cloudBot.ts # Discord bot management
546
+ │ │ └── dCloud.ts # Main upload/download logic
547
+ │ ├── interface/
548
+ │ │ └── index.ts # TypeScript interfaces
549
+ │ ├── utils/
550
+ │ │ ├── 7zip.ts # 7-Zip compression utilities
551
+ │ │ └── lib.ts # Helper functions
552
+ │ └── index.ts # Entry point & examples
553
+ ├── dist/ # Compiled JavaScript (auto-generated)
554
+ ├── node_modules/ # Dependencies (auto-generated)
555
+ ├── eslint.config.ts # ESLint rules
556
+ ├── tsconfig.json # TypeScript configuration
557
+ ├── package.json # Dependencies & npm scripts
558
+ ├── index.d.ts # Public API type definitions
559
+ └── README.md # This documentation
560
+ ```
561
+
562
+ ### Directory Breakdown
563
+
564
+ | Directory | Purpose |
565
+ | ------------------ | ---------------------------------- |
566
+ | **src/** | TypeScript source code |
567
+ | **src/classes/** | Core DCloud and CloudBot classes |
568
+ | **src/interface/** | Type definitions and interfaces |
569
+ | **src/utils/** | Utility functions (7-Zip, helpers) |
570
+ | **dist/** | Compiled JavaScript output |
571
+
572
+ ---
573
+
574
+ ## 📋 Scripts & Commands
575
+
576
+ ### Development Commands
577
+
578
+ | Command | Purpose | Usage |
579
+ | -------------------- | ------------------------ | -------------------- |
580
+ | `npm run dev` | Start with auto-reload | `npm run dev` |
581
+ | `npm run build` | Compile TypeScript | `npm run build` |
582
+ | `npm run type-check` | Check types without emit | `npm run type-check` |
583
+ | `npm run lint` | Run ESLint | `npm run lint` |
584
+
585
+ ### Production Commands
586
+
587
+ | Command | Purpose |
588
+ | --------------- | ---------------------- | ----------------------------------- |
589
+ | `npm start` | Build and run | Compiles and executes compiled code |
590
+ | `npm run build` | TypeScript compilation | Creates `dist/` folder |
591
+
592
+ ### Quick Reference
593
+
594
+ ```bash
595
+ # Development workflow
596
+ npm install # Install dependencies
597
+ npm run dev # Start development server
598
+
599
+ # Before committing
600
+ npm run lint # Check code quality
601
+ npm run type-check # Verify types
602
+
603
+ # Production deployment
604
+ npm run build # Compile code
605
+ npm start # Run compiled version
606
+ ```
607
+
608
+ ---
609
+
610
+ ## 🔧 Development
611
+
612
+ ### Code Quality
613
+
614
+ #### ESLint Configuration
615
+
616
+ The project uses ESLint with TypeScript support:
617
+
618
+ ```bash
619
+ npm run lint
620
+ ```
621
+
622
+ Config file: `eslint.config.ts`
623
+
624
+ #### TypeScript Validation
625
+
626
+ Verify types and compilation:
627
+
628
+ ```bash
629
+ npm run type-check # Check types without emitting
630
+ npm run build # Full compilation to JavaScript
631
+ ```
632
+
633
+ ### Development Workflow
634
+
635
+ 1. **Write Code**: Create TypeScript files in `src/`
636
+ 2. **Test Locally**: Use `npm run dev` for auto-reload testing
637
+ 3. **Validate**: Run `npm run type-check` to check types
638
+ 4. **Lint**: Run `npm run lint` to check code quality
639
+ 5. **Build**: Run `npm run build` to verify compilation
640
+ 6. **Test Complete Flow**: Manually test upload/download
641
+ 7. **Commit**: Push changes once verified
642
+
643
+ ### Adding Features
644
+
645
+ #### Step 1: Define Types
646
+
647
+ Add interfaces to `src/interface/index.ts`:
648
+
649
+ ```typescript
650
+ export interface IMyFeature {
651
+ name: string;
652
+ value: number;
653
+ }
654
+ ```
655
+
656
+ #### Step 2: Create Utilities
657
+
658
+ Add functions to `src/utils/`:
659
+
660
+ ```typescript
661
+ export function myUtility(input: string): string {
662
+ return input.toUpperCase();
663
+ }
664
+ ```
665
+
666
+ #### Step 3: Add Methods
667
+
668
+ Update classes in `src/classes/`:
669
+
670
+ ```typescript
671
+ public async myMethod(param: string): Promise<void> {
672
+ // Implementation
673
+ }
674
+ ```
675
+
676
+ #### Step 4: Update Public API
677
+
678
+ Export in `index.d.ts`:
679
+
680
+ ```typescript
681
+ export { myUtility } from "./src/utils/lib";
682
+ ```
683
+
684
+ ---
685
+
686
+ ## 🐛 Troubleshooting
687
+
688
+ ### Bot Connection Issues
689
+
690
+ **Problem**: "Could not find server with ID"
691
+
692
+ **Solution**:
693
+
694
+ - Verify your `SERVER_ID` is correct
695
+ - Ensure the bot is invited to the server
696
+ - Check bot permissions in server settings
697
+
698
+ **Problem**: "Channel ID provided is not a Forum Channel"
699
+
700
+ **Solution**:
701
+
702
+ - Verify you're using a forum channel, not a regular channel
703
+ - Right-click the channel in Discord to confirm it's a forum
704
+ - Get the correct channel ID
705
+
706
+ ### Upload Failures
707
+
708
+ **Problem**: "File not found at path"
709
+
710
+ **Solution**:
711
+
712
+ - Use absolute paths (e.g., `C:\\Users\\...`)
713
+ - Verify the file exists before uploading
714
+ - Check file permissions (must be readable)
715
+
716
+ **Problem**: "Bot is not online"
717
+
718
+ **Solution**:
719
+
720
+ - Call `await dCloud.init()` before uploading
721
+ - Verify bot token is correct and still valid
722
+ - Check bot permissions in Discord server
723
+
724
+ ### Compression Issues
725
+
726
+ **Problem**: "7-Zip binary not found"
727
+
728
+ **Solutions**:
729
+
730
+ - Reinstall dependencies: `npm install`
731
+ - Ensure `7zip-bin` package is properly installed
732
+ - On Linux, install p7zip: `sudo apt-get install p7zip-full`
733
+ - On macOS: `brew install p7zip`
734
+
735
+ **Problem**: "Input path does not exist"
736
+
737
+ **Solutions**:
738
+
739
+ - Verify file path is absolute and correct
740
+ - Check file permissions (must be readable)
741
+ - Use forward slashes or escaped backslashes in paths
742
+
743
+ ### Memory & Performance Issues
744
+
745
+ **Problem**: "FATAL ERROR: CALL_AND_RETRY_LAST"
746
+
747
+ **Solutions**:
748
+
749
+ - Increase Node.js memory limit:
750
+ ```bash
751
+ node --max-old-space-size=4096 dist/index.js
752
+ ```
753
+ - Reduce file size being compressed
754
+ - Monitor system resources and close unnecessary applications
755
+
756
+ **Problem**: Slow uploads to Discord
757
+
758
+ **Solutions**:
759
+
760
+ - Check internet connection speed
761
+ - Add delays between uploads: `setTimeout(...)`
762
+ - Use exponential backoff for retries
763
+ - Consider uploading during off-peak hours
764
+
765
+ ### Discord Rate Limiting
766
+
767
+ **Problem**: "429 Too Many Requests"
768
+
769
+ **Causes**: Discord API rate limiting (20 requests/sec per channel)
770
+
771
+ **Solutions**:
772
+
773
+ - Add delays between file uploads
774
+ - Implement exponential backoff retry logic:
775
+ ```typescript
776
+ let retries = 0;
777
+ while (retries < 3) {
778
+ try {
779
+ await dCloud.upload(filePath);
780
+ break;
781
+ } catch (e) {
782
+ await new Promise((r) => setTimeout(r, Math.pow(2, retries) * 1000));
783
+ retries++;
784
+ }
785
+ }
786
+ ```
787
+ - Split uploads across multiple bot instances
788
+
789
+ ---
790
+
791
+ ## 📊 Performance & Benchmarks
792
+
793
+ ### Compression Metrics
794
+
795
+ | Metric | Value |
796
+ | --------------------- | ----------------------------- |
797
+ | **Algorithm** | LZMA2 with 512MB dictionary |
798
+ | **Compression Ratio** | 40-70% (file type dependent) |
799
+ | **Speed** | ~10-50 MB/min (CPU dependent) |
800
+ | **Dictionary Size** | 512MB (maximum) |
801
+
802
+ ### Upload Performance
803
+
804
+ | Metric | Value |
805
+ | ---------------------- | ------------------------------------- |
806
+ | **Discord Rate Limit** | 20 requests/sec per channel |
807
+ | **Typical Speed** | 50-200 MB/hour |
808
+ | **Segment Size** | 8MB (safe margin below Discord limit) |
809
+ | **Bottleneck** | Discord API rate limiting |
810
+
811
+ ### Optimal File Types
812
+
813
+ | Category | Best For | Avoid |
814
+ | ------------- | --------------------------------------- | ---------------------------------- |
815
+ | **Text** | Source code, logs, documents | Already compressed files |
816
+ | **Media** | High-quality images, uncompressed video | MP4, JPG, PNG (already compressed) |
817
+ | **Archives** | ZIP/RAR before uploading | Don't double-compress |
818
+ | **Databases** | Raw database files, backups | Encrypted archives |
819
+
820
+ - Poor for: Already compressed files (zip, mp4, jpg)
821
+
822
+ ---
823
+
824
+ ## 📝 Example Workflow
825
+
826
+ ### Complete Upload Example
827
+
828
+ ```typescript
829
+ import { DCloud } from "./src/classes/dCloud.js";
830
+ import fs from "fs";
831
+
832
+ async function uploadExample() {
833
+ const dCloud = DCloud({
834
+ TOKEN: process.env.DISCORD_TOKEN || "YOUR_TOKEN",
835
+ SERVER_ID: process.env.DISCORD_SERVER_ID || "YOUR_SERVER_ID",
836
+ FORUM_CHANNEL_ID: process.env.DISCORD_FORUM_CHANNEL_ID || "YOUR_FORUM_ID",
837
+ });
838
+
839
+ try {
840
+ // Step 1: Initialize bot connection
841
+ console.log("🤖 Initializing bot...");
842
+ await dCloud.init();
843
+
844
+ // Step 2: Upload file
845
+ console.log("📤 Starting upload...");
846
+ const result = await dCloud.upload("C:\\files\\backup.zip");
847
+
848
+ // Step 3: Display results
849
+ console.log("✅ Upload successful!");
850
+ console.log(`📦 Name: ${result.originalName}`);
851
+ console.log(`📊 Size: ${result.totalSize}`);
852
+ console.log(`🔗 Metadata: ${result.metadata}`);
853
+
854
+ // Step 4: Save metadata URL for later
855
+ fs.writeFileSync("upload_metadata.json", JSON.stringify(result, null, 2));
856
+ console.log("💾 Metadata saved to upload_metadata.json");
857
+ } catch (error) {
858
+ console.error("❌ Upload failed:", error);
859
+ }
860
+ }
861
+
862
+ uploadExample();
863
+ ```
864
+
865
+ ### Using NPM Package - Complete Download Example
866
+
867
+ ```typescript
868
+ import { DCloud } from "dc-cloud";
869
+
870
+ async function downloadExample() {
871
+ const dCloud = DCloud({
872
+ TOKEN: process.env.DISCORD_TOKEN || "YOUR_TOKEN",
873
+ SERVER_ID: process.env.DISCORD_SERVER_ID || "YOUR_SERVER_ID",
874
+ FORUM_CHANNEL_ID: process.env.DISCORD_FORUM_CHANNEL_ID || "YOUR_FORUM_ID",
875
+ });
876
+
877
+ try {
878
+ // Step 1: Initialize bot
879
+ console.log("🤖 Initializing bot...");
880
+ await dCloud.init();
881
+
882
+ // Step 2: Download and restore
883
+ console.log("📥 Starting download...");
884
+ await dCloud.downloader(
885
+ "https://cdn.discordapp.com/attachments/.../metadata.json",
886
+ "C:\\restored\\",
887
+ );
888
+
889
+ console.log("✅ Download and extraction complete!");
890
+ console.log("📁 Files restored to C:\\restored\\");
891
+ } catch (error) {
892
+ console.error("❌ Download failed:", error);
893
+ }
894
+ }
895
+
896
+ downloadExample();
897
+ ```
898
+
899
+ ---
900
+
901
+ ## 📚 Additional Resources
902
+
903
+ ### Discord Developer Portal
904
+
905
+ - [Applications](https://discord.com/developers/applications)
906
+ - [Bot Documentation](https://discord.com/developers/docs/intro)
907
+ - [Gateway Intents](https://discord.com/developers/docs/topics/gateway#gateway-intents)
908
+
909
+ ### Related Libraries
910
+
911
+ - [Discord.js Documentation](https://discord.js.org)
912
+ - [7-Zip Documentation](https://www.7-zip.org)
913
+ - [Node.js Child Process](https://nodejs.org/api/child_process.html)
914
+
915
+ ---
916
+
917
+ ## 📄 License
918
+
919
+ This project is marked as **private**. Please contact the author for licensing information.
920
+
921
+ ---
922
+
923
+ ## 👤 Author
924
+
925
+ **Neel Frostrain** (@NeelFrostrain)
926
+
927
+ - **GitHub**: [NeelFrostrain](https://github.com/NeelFrostrain)
928
+ - **Repository**: [DCloud](https://github.com/NeelFrostrain/DCloud)
929
+
930
+ ---
931
+
932
+ ## 🤝 Contributing
933
+
934
+ Contributions are welcome! Here's how to contribute:
935
+
936
+ 1. **Fork** the repository
937
+ 2. **Create** a feature branch: `git checkout -b feature/amazing-feature`
938
+ 3. **Commit** changes: `git commit -m 'Add amazing feature'`
939
+ 4. **Push** to branch: `git push origin feature/amazing-feature`
940
+ 5. **Open** a Pull Request
941
+
942
+ ### Development Guidelines
943
+
944
+ - Write in TypeScript
945
+ - Follow existing code style (use `npm run lint`)
946
+ - Test all changes locally
947
+ - Update documentation as needed
948
+ - Include meaningful commit messages
949
+
950
+ ---
951
+
952
+ ## ❓ FAQ
953
+
954
+ ### General Questions
955
+
956
+ **Q: Is my data safe on Discord?**
957
+
958
+ A: Data is encrypted via Discord's HTTPS connections. However, Discord can theoretically access encrypted messages. For sensitive data, consider additional encryption.
959
+
960
+ **Q: What's the maximum file size I can upload?**
961
+
962
+ A: Theoretical limit depends on Discord storage. Each bot account can upload ~5GB before approaching limits. Use multiple bot accounts for larger backups.
963
+
964
+ **Q: Can I use multiple bot instances?**
965
+
966
+ A: Yes! You can scale horizontally by deploying multiple bot instances across different Discord servers.
967
+
968
+ **Q: How long do uploaded files stay on Discord?**
969
+
970
+ A: As long as the Discord message exists. Discord stores messages indefinitely unless deleted. Your responsibility is to maintain backup URLs.
971
+
972
+ ### Technical Questions
973
+
974
+ **Q: Can I use different compression algorithms?**
975
+
976
+ A: Currently, LZMA2 is hardcoded. You can modify `src/utils/7zip.ts` to support other algorithms (PPMd, BZip2, etc.).
977
+
978
+ **Q: How do I reduce upload time?**
979
+
980
+ A: Options:
981
+
982
+ 1. Compress pre-upload (though files are already compressed)
983
+ 2. Use multiple bot instances
984
+ 3. Increase Discord API request limits if possible
985
+ 4. Optimize network connection
986
+
987
+ **Q: Can I restore files partially?**
988
+
989
+ A: No, the current implementation requires all segments. You must restore complete archives.
990
+
991
+ **Q: Does DCloud support streaming uploads?**
992
+
993
+ A: No, currently uses buffer-based uploads. Streaming support could be added as a future feature.
994
+
995
+ ### Troubleshooting Questions
996
+
997
+ **Q: Bot is not responding?**
998
+
999
+ A: Check:
1000
+
1001
+ 1. Bot token is correct
1002
+ 2. Bot is invited to server
1003
+ 3. Forum channel exists and bot has access
1004
+ 4. Internet connection is stable
1005
+
1006
+ **Q: Uploads are very slow?**
1007
+
1008
+ A: Causes and solutions:
1009
+
1010
+ - **Network**: Check internet speed
1011
+ - **CPU**: Compression is CPU-intensive
1012
+ - **Discord Rate Limit**: Add delays between uploads
1013
+ - **Large Files**: Break into smaller chunks before uploading
1014
+
1015
+ **Q: Can I cancel an upload in progress?**
1016
+
1017
+ A: Not gracefully in the current version. You'd need to kill the process. Consider adding cancellation tokens in future versions.
1018
+
1019
+ ---
1020
+
1021
+ ## 🐛 Known Limitations
1022
+
1023
+ - ⚠️ No partial restoration (must restore entire archives)
1024
+ - ⚠️ Single-threaded uploads (can be optimized)
1025
+ - ⚠️ No built-in encryption (Discord HTTPS provides some protection)
1026
+ - ⚠️ Metadata URLs may expire if Discord messages are deleted
1027
+ - ⚠️ No support for incremental backups (only full backups)
1028
+
1029
+ ---
1030
+
1031
+ ## 🚀 Future Enhancements
1032
+
1033
+ Planned features for future versions:
1034
+
1035
+ - [ ] Incremental backup support
1036
+ - [ ] Built-in encryption layer
1037
+ - [ ] Progress tracking UI
1038
+ - [ ] Scheduled automatic backups
1039
+ - [ ] Multi-threaded uploads
1040
+ - [ ] Compression algorithm selection
1041
+ - [ ] WebUI dashboard
1042
+ - [ ] REST API interface
1043
+
1044
+ ---
1045
+
1046
+ ## 📞 Support
1047
+
1048
+ ### Getting Help
1049
+
1050
+ 1. Check [Troubleshooting](#-troubleshooting) section
1051
+ 2. Review existing [GitHub Issues](https://github.com/NeelFrostrain/DCloud/issues)
1052
+ 3. Create a new issue with:
1053
+ - Error message and logs
1054
+ - Steps to reproduce
1055
+ - System information (OS, Node.js version)
1056
+ - DCloud version
1057
+
1058
+ ### Reporting Bugs
1059
+
1060
+ When reporting bugs, include:
1061
+
1062
+ - Full error stack trace
1063
+ - Console output
1064
+ - File/folder being uploaded
1065
+ - System specifications
1066
+
1067
+ ---
1068
+
1069
+ **Made with ❤️ for the Discord community**
1070
+
1071
+ **Last Updated**: January 26, 2026
1072
+ **Version**: 0.0.1
1073
+
1074
+ To install dependencies:
1075
+
1076
+ ```bash
1077
+ bun install
1078
+ ```
1079
+
1080
+ To run:
1081
+
1082
+ ```bash
1083
+ bun run index.ts
1084
+ ```
1085
+
1086
+ This project was created using `bun init` in bun v1.3.5. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.