Turns Discord into a datastore that can manage and store your files.
DDrive A lightweight cloud storage system using discord as storage device written in nodejs. Supports unlimited file size and unlimited storage, I've implemented it using node js streams with multi-part up & download.
ddrive_demo.mp4
- Theoretically unlimited file size thanks to splitting the file in 8mb chunks using nodejs streams API.
- Simple yet robust HTTP front end
- Tested with storing 4000 GB of data on single discord channel (With max file size of 16GB).
- Supports basic auth for site.
- Easily deploy on heroku/repl.it and use as private cloud storage.(Use
ddrive v1
on repl, repl doesn't support node version 16 yet)
- NodeJS v16.x or Docker
- Discord bot token, Text Channel ID
- Creating the bot - In order for this program to work, you're going to need to create a discord bot, so we can connect to the discord API. Go to this link to create a bot. Make sure to create a user bot, ensure the bot is private and message content intent is enabled. Here's a picture to the configuration. Keep note of the token and the client ID.
- Setting up server - The bot will need a place to upload files. Create a new discord server, make sure no one else is on it unless you want them to access your files.
- Adding your bot to the server - To add the bot to the server (assuming your bot isn't public), go to the following link: https://discordapp.com/oauth2/authorize?client_id={CLIENT_ID}&scope=bot&permissions=0 Replace {CLIENT_ID} with the client ID you copied earlier. Then, select the server you just made and authorize. Your server should now show your bot like this.
- Copy channelId - Right click on text channel and click on
Copy Id
. If you don't see this option, goto settings -> Advanced -> Enable developer mode. - By now you should have
bot token
andtext channel id
.
npm install -g @forscht/ddrive
ddrive --token <bot token> --channelId <guild channel id>
# Open http://localhost:8080 in browser
# use <ddrive help> for more info
docker run --rm -p 8080:8080 -it forscht/ddrive --port 8080 --token <bot-token> --channelId <guild-channel-id>
# Open http://localhost:8080 in browser
# use <docker run --rm -it forscht/ddrive help> for more info
#Linux / MacOS
DDRIVE_TOKEN=<bot token> DDRIVE_CHANNEL_ID=<channel id> pm2 start ddrive
#Windows CMD
set DDRIVE_TOKEN=<bot token> set DDRIVE_CHANNEL_ID=<channel id> pm2 start ddrive
#Windows powershell
$env:DDRIVE_TOKEN="<bot token>"
$env:DDRIVE_CHANNEL="<channel id>"
pm2 start ddrive
#ERROR
# ddrive : File C:\Users\<User>\AppData\Roaming\npm\ddrive.ps1 cannot be loaded because running scripts is disabled on this system. For more information
1. Open powershell as Administrator
2. run `set-executionpolicy remotesigned`
DDRIVE - A lightweight cloud storage system using discord as storage device written in nodejs.
Options:
--help Show help [boolean]
--version Show version number [boolean]
-P, --httpPort Port of HTTP server [number]
-A, --auth Username password separated by ":". ie - admin:password
[string]
-T, --token Discord bot/user token [string] [required]
-C, --channelId Text channel id where data will be stored [string] [required]
--config Path to JSON config file
process.env.DEBUG = '*'
const { DiscordFS, HttpServer } = require('@forscht/ddrive')
const token = '' // Discord bot token
const channelId = '' // Text channelId
const httpPort = 8080 // Ddrive site port
const auth = '' // Basic auth for ddrive site. Format - username:password
// If you have slow internet connection and facing user aborted request error
// increase request timeout limit.
// Other available options // https://github.com/discordjs/discord.js/blob/c25e8ad78b1a020a24ec50e30dd7315234ce9309/packages/rest/src/lib/REST.ts#L21
const restOpts = {
timeout: '60000',
}
const chunkSize = 7864320 // Default 7.8 MB
const run = async () => {
const discordFS = new DiscordFS({
token, channelId, rest: restOpts, chunkSize,
})
await discordFS.load() // Read files from text channel and build metadata. Might take time depending on storage size
const httpServer = new HttpServer(discordFS, { httpPort, auth })
await httpServer.build() // Finally, start http server here
}
run().then()