discord-bot-client icon indicating copy to clipboard operation
discord-bot-client copied to clipboard

[Question] Source code refactoring.

Open Nitrrine opened this issue 4 years ago • 10 comments

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 avatar Dec 08 '20 12:12 Nitrrine

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

Nitrrine avatar Dec 08 '20 12:12 Nitrrine

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 avatar Dec 08 '20 18:12 SamuelScheit

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

SamuelScheit avatar Apr 03 '21 17:04 SamuelScheit

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

ShreyasAyyengar avatar Apr 16 '21 02:04 ShreyasAyyengar

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?

ar065 avatar Jun 25 '21 17:06 ar065

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

SamuelScheit avatar Jun 25 '21 17:06 SamuelScheit

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

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

ar065 avatar Jun 25 '21 17:06 ar065

Hmm it doesn't work with latest sources

ar065 avatar Jun 25 '21 18:06 ar065

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)

DodoGames7 avatar Aug 02 '21 18:08 DodoGames7

nvm i will try again

DodoGames7 avatar Aug 02 '21 18:08 DodoGames7