Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

[Question] Source code refactoring. #198

Open
Nitrrine opened this issue Dec 8, 2020 · 10 comments
Open

[Question] Source code refactoring. #198

Nitrrine opened this issue Dec 8, 2020 · 10 comments
Labels
good first issue Good for newcomers

Comments

@Nitrrine
Copy link

Nitrrine commented Dec 8, 2020

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
Copy link
Author

Nitrrine commented Dec 8, 2020

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

@SamuelScheit
Copy link
Owner

SamuelScheit commented Dec 8, 2020

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 SamuelScheit added bug Something isn't working good first issue Good for newcomers and removed bug Something isn't working labels Apr 3, 2021
@SamuelScheit
Copy link
Owner

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
Copy link

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

@ar065
Copy link

ar065 commented Jun 25, 2021

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
Copy link
Owner

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

@ar065
Copy link

ar065 commented Jun 25, 2021

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

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

@ar065
Copy link

ar065 commented Jun 25, 2021

Hmm it doesn't work with latest sources

@ddodogames
Copy link

ddodogames commented Aug 2, 2021

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
Copy link

nvm i will try again

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants
@SamuelScheit @Nitrrine @ar065 @ShreyasAyyengar @ddodogames and others