Giter Site home page Giter Site logo

discord-fs's Introduction

discord-fs

discord-fs is a Discord bot that allows creating an encrypted virtual file system accesible via FTP, backed by text-messages for journaling and attachments for storage. The maximum file size limit is 8mb. For bigger files i've implemented multi-part up & download. There is no limit in the amount of files in theory.

Features

  • Theoretically unlimited file size thanks to splitting the file in 8mb chunks (discord is quite unreliable when it comes to uploading 20 files in a row without any issues)
  • FTP frontend
  • HTTP frontend (up & downloading) I've disabled it for now because of building complications on windows. You may wanna tinker with it, to enable, uncomment the lines in GuildStorageHandler.ts
  • (Incomplete) fuse frontend
  • optional AES-256-CBC encryption (with per file iv, unreadable journal)

Installation & Preparation

If you haven't already created a discord bot, follow the following steps:

Create a Discord bot identity

  1. Create a new application on https://discord.com/developers/applications
  2. Select your new app, navigate to "Bot" in the sidebar, "Add Bot", copy its Token
  3. Navigate to "OAuth2" in the sidebar, write down your "Client ID"
  4. Fill in http://localhost as Redirect above "Add Redirect" and save the form

Invite the Discord bot to your guild

  1. Complete the following url with your client id: https://discord.com/oauth2/authorize?response_type=code&client_id=YOUR_CLIENT_ID_HERE&scope=bot
  2. Navigate to the url and let the bot join your preferred guild

You can obtain your guild and channel snowflake (its id) by enabling developer mode on your Discord client (User Settings > Advanced > Developer Mode) and rightclicking both the guilds name or the specifc channel and choose "Copy ID" from the context menu.

Quick Start

You can clone or fork this repo and start from there (recommended if you want to make changes).

git clone https://github.com/fr34kyn01535/discord-fs.git
cd discord-fs
npm install

and then run the code from git repository

#EXAMPLE for your ba/z/shell of choice
export GUILD=536667092276215811 #The guild snowflake
export CHANNEL=536667818452582411 #The channel snowflake
export TOKEN=_6qrZcUqja7812RVdnEKjpzOL4CvHB123qrZcUqja7812RVdnEKjpzOL4CvHBFG #Your discord bot api token
export AES_KEY=BAM~NOBODY~GUESSES_this_:D #If you don't want encrpytion, keep this empty, otherwise roll a new secret

export LISTEN_IP=127.0.0.1 #IP the FTP server will listen on
export EXTERNAL_IP=127.0.0.1 #IP reported to passive FTP connections (Set it to your external ip)
export FTP_PORT=33333 #Port the FTP server will listen on
export HTTP_PORT=1338 #Port the web frontend will listen on

npm start

or directly download and launch the bot as-is from GitHub using npx.

#EXAMPLE for PowerShell
$ENV:GUILD="536667092276215811" #The guild snowflake
$ENV:CHANNEL="536667818452582411" #The channel snowflake
$ENV:TOKEN="_6qrZcUqja7812RVdnEKjpzOL4CvHB123qrZcUqja7812RVdnEKjpzOL4CvHBFG" #Your discord bot api token
$ENV:AES_KEY="BAM~NOBODY~GUESSES_this_:D" #If you don't want encrpytion, keep this empty, otherwise roll a new secret

$ENV:LISTEN_IP="127.0.0.1" #IP the FTP server will listen on
$ENV:EXTERNAL_IP="127.0.0.1" #IP reported to passive FTP connections (Set it to your external ip)
$ENV:FTP_PORT="33333" #Port the FTP server will listen on
$ENV:HTTP_PORT="1338" #Port the web frontend will listen on

npx git+https://github.com/fr34kyn01535/discord-fs

Contributing

At this point discord-fs is pretty mutch just a POC. Pull requests are welcome.

License

MIT

discord-fs's People

Contributors

azeyrx avatar dependabot[bot] avatar fr34kyn01535 avatar shrootbuck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

discord-fs's Issues

won't start

Hi, I was trying to run this, however...

npm start results in "missing script: start" ๐Ÿค”

Tuxi

Cannot startup !


> [email protected] start
> tsc --build tsconfig.json && node index.js

node_modules/discord.js/typings/index.d.ts:477:14 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<Cached>'.

477   ): Promise<MappedInteractionTypes<Cached>[T]>;
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:480:27 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'CollectedInteraction<CacheType>'.
  Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'ButtonInteraction<CacheType>'.

480   ): InteractionCollector<MappedInteractionTypes<Cached>[T]>;
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:480:27 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<Cached>'.

480   ): InteractionCollector<MappedInteractionTypes<Cached>[T]>;
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1660:42 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'CollectedMessageInteraction<CacheType>'.
  Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'ButtonInteraction<CacheType>'.

1660     } & MessageComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1660:42 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<Cached>'.

1660     } & MessageComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1665:49 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'CollectedMessageInteraction<CacheType>'.
  Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'ButtonInteraction<CacheType>'.

1665     } & MessageChannelComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1665:49 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<Cached>'.

1665     } & MessageChannelComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1669:35 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'CollectedInteraction<CacheType>'.
  Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'ButtonInteraction<CacheType>'.

1669       InteractionCollectorOptions<MappedInteractionTypes<Cached>[T]>,
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1669:35 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<Cached>'.

1669       InteractionCollectorOptions<MappedInteractionTypes<Cached>[T]>,
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1733:14 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<InGuild>'.

1733   ): Promise<MappedInteractionTypes<InGuild>[T]>;
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1738:27 - error TS2344: Type 'MappedInteractionTypes<InGuild>[T]' does not satisfy the constraint 'CollectedInteraction<CacheType>'.
  Type 'MappedInteractionTypes<InGuild>[T]' is not assignable to type 'ButtonInteraction<CacheType>'.

1738   ): InteractionCollector<MappedInteractionTypes<InGuild>[T]>;
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:1738:27 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<InGuild>'.

1738   ): InteractionCollector<MappedInteractionTypes<InGuild>[T]>;
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:3795:14 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<boolean>'.

3795   ): Promise<MappedInteractionTypes[T]>;
                  ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:3803:27 - error TS2344: Type 'MappedInteractionTypes<boolean>[T]' does not satisfy the constraint 'CollectedInteraction<CacheType>'.
  Type 'MappedInteractionTypes<boolean>[T]' is not assignable to type 'ButtonInteraction<CacheType>'.

3803   ): InteractionCollector<MappedInteractionTypes[T]>;
                               ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/discord.js/typings/index.d.ts:3803:27 - error TS2536: Type 'T' cannot be used to index type 'MappedInteractionTypes<boolean>'.

3803   ): InteractionCollector<MappedInteractionTypes[T]>;
                               ~~~~~~~~~~~~~~~~~~~~~~~~~


Found 15 errors.

OS: Fedora 37

ftp directory handling doesn't seem to work properly, sometimes results in multiple same name folders

ftp directory handling doesn't seem to work properly, especially try to upload a folder,
which would normally create the folder and cwd into it. But the current behavior is upload a folder will usually create it, but CWD into it will fail.

Manually create a folder, then cdw into it works.

This sometimes results in multiple same name folders due to the client retry creating the folder.
Then if delete the folders sometimes you would delete the wrong folder due to client side caching maybe.

FTP connection: "Error: This socket has been ended by the other party" When downloading large files.

Error when trying to download file from FTP protocol using filezila. This happened after the first file has been downloaded and trying to download a second file. File size is 650 MB

Update: This only happened on FTP connection, download file using web interface is fine.

node:internal/errors:857
  const err = new Error(message);
              ^

Error: This socket has been ended by the other party
    at Socket.writeAfterFIN [as write] (node:net:521:14)
    at /home/pi/discord-fs/node_modules/simple-ftpd/lib/util/promisify.js:8:14
    at new Promise (<anonymous>)
    at Socket.<anonymous> (/home/pi/discord-fs/node_modules/simple-ftpd/lib/util/promisify.js:5:12)
    at Session.respond (/home/pi/discord-fs/node_modules/simple-ftpd/lib/session.js:177:30)
    at /home/pi/discord-fs/node_modules/simple-ftpd/lib/session.js:145:19
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'EPIPE'
}

JSON.parse Failed to parse json

This package is broken and does not work.

complete log https://dpaste.com/4BNE3ZMS5.txt

/.git/discord-fs $ cd ..
seeder@isoseeder95 ~/.git $ cd discord-fs/
seeder@isoseeder95 ~/.git/discord-fs $ ls
index.ts package.json README.md tsconfig.json
LICENSE package-lock.json src
seeder@isoseeder95 ~/.git/discord-fs $ npm install
npm ERR! code EJSONPARSE
npm ERR! file /home/seeder/.git/discord-fs/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 127 while parsing '{
npm ERR! JSON.parse "name": "discord-storage-ftp",
npm ERR! JSON.parse "ve'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/seeder/.npm/_logs/2020-10-31T19_15_45_117Z-debug.log

thanks for that

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.