SamuelScheit / discord-bot-client

A patched version of discord, with bot login support
685 stars 413 forks source link

[Question] Source code refactoring. #198

Open Nitrrine opened 3 years ago

Nitrrine commented 3 years ago

Hello developer! Can the source code for this client be modified for me? Here's what I mean: I'll download the source code for the client, and I'll try to fix the bugs. If I can fix at least one bug, can I create a repository on github? (I'll list the author and original repository)

Nitrrine commented 3 years ago

Addition: I know at an intermediate level HTML, CSS, JS.

SamuelScheit commented 3 years ago

You need to install NodeJS and NPM then install the dependencies:

npm i -g electron
git clone https://github.com/Flam3rboy/discord-bot-client/
cd discord-bot-client/electron/

you need to make a few changes: in electron/index.js at the first line insert this:

const fs = require("fs/promises");

and at line 10 insert this:

html = fs.readFile(__dirname + "/../index.html");

this will load your local index.html file instead of the github hosted one. Now you can make changes to index.html, and restart the application after a editing the file:

electron . 

the index.html file will download the discord js source, searches for the relevant file and patches it. you can just make a pull request if you are finished.

SamuelScheit commented 3 years ago

update version: ^ follow the instructions above, then load the https://discord.com/app site after the site loaded you press Ctrl + S to save all the files. Now you should have all the JS files of discord and can make changes to the index.html file. Now you must patch all the changed variable names: e.g. old:

const fixAffinities = fixLibraryApplications.replace(
        ",r.default.get({url:i.Endpoints.USER_AFFINITIES,retries:e?3:0}).then((function(e){var t=e.body;a.default.dispatch({type:i.ActionTypes.LOAD_USER_AFFINITIES_SUCCESS,affinities:t})}),(function(){a.default.dispatch({type:i.ActionTypes.LOAD_USER_AFFINITIES_FAILURE})}))):Promise.resolve()",
        `,setTimeout(()=>{
var exampleAffinities =  {"user_affinities": [], "inverse_user_affinities": []}
a.default.dispatch({
    type: i.ActionTypes.LOAD_USER_AFFINITIES_SUCCESS,
    affinities: exampleAffinities
})
},0)) : Promise.resolve()`
    );

new:

const fixAffinities = fixLibraryApplications.replace(
        ",l.default.get({url:i.Endpoints.USER_AFFINITIES,retries:e?3:0}).then((function(h){var t=h.body;j.default.dispatch({type:i.ActionTypes.LOAD_USER_AFFINITIES_SUCCESS,affinities:t})}),(function(){a.default.dispatch({type:i.ActionTypes.LOAD_USER_AFFINITIES_FAILURE})}))):Promise.resolve()",
        `,setTimeout(()=>{
var exampleAffinities =  {"user_affinities": [], "inverse_user_affinities": []}
j.default.dispatch({
    type: i.ActionTypes.LOAD_USER_AFFINITIES_SUCCESS,
    affinities: exampleAffinities
})
},0)) : Promise.resolve()`
    );

^ notice the changed variable names (r -> l, a -> j, e -> h)

if you want to make it compatible with all futures version you could instead convert the search and replace strings to regular expressions

ShreyasAyyengar commented 3 years ago

@BuilderHD Have you made a newer version of the bot client / is it available for download?

ar065 commented 3 years ago

You need to install NodeJS and NPM then install the dependencies:

npm i -g electron
git clone https://github.com/Flam3rboy/discord-bot-client/
cd discord-bot-client/electron/

you need to make a few changes: in electron/index.js at the first line insert this:

const fs = require("fs/promises");

and at line 10 insert this:

html = fs.readFile(__dirname + "/../index.html");

this will load your local index.html file instead of the github hosted one. Now you can make changes to index.html, and restart the application after a editing the file:

electron . 

the index.html file will download the discord js source, searches for the relevant file and patches it. you can just make a pull request if you are finished.

How would I get the latest source?

SamuelScheit commented 3 years ago

download the html from https://discord.com/app

ar065 commented 3 years ago

download the html from https://discord.com/app

This works too right? https://canary.discord.com/app

ar065 commented 3 years ago

Hmm it doesn't work with latest sources

ddodogames commented 3 years ago

i tried updating it replacing .js files and CSS with new one but it didn't work too (i actually ended up to give up)

ddodogames commented 3 years ago

nvm i will try again