Comments (10)
How does the website work? I'm trying to create a JavaScript code snippet to allow me to login as a bot on the official discord.com website. While I can easily set the bot token in the localStorage, I cannot connect because of the websocket missing the bot intents. I can't find the code about the /login route in this repository, but I might just be blind.
If you are missing intents, this website is old enough to not need them since its using API v6 (v7 works too) and doesn't need them. v8+ does. You would have to patch the gateway code to use intents somewhere in the assets.
from chriseric1.github.io.
I have a snippet which works perfectly, but I don't know how to apply it to discord.com
const ws = new WebSocket('wss://gateway.discord.gg/?v=9&encoding=json');
let interval = 0;
const token = 'BOT TOKEN HERE';
const payload = {
op: 2,
d: {
token: token,
intents: 3276799,
properties: {
$os: 'linux',
$browser: 'chrome',
$device: 'chrome',
},
compress: false,
},
};
let lastS = -1;
ws.addEventListener('open', () => {
console.log('Connected to Discord Gateway');
ws.send(JSON.stringify(payload));
});
ws.addEventListener('message', (e) => {
const payload = JSON.parse(e.data);
const { t, d, op, s } = payload;
console.log(`[dispatch event: ${t} - seq: ${s}] opcode:`, op, `response:`, d);
if (s) lastS = s;
if (op === 10) {
const { heartbeat_interval } = d;
let interval = setInterval(() => {
ws.send(
JSON.stringify({
op: 1,
d: lastS === -1 ? null : lastS,
})
);
}, heartbeat_interval);
}
});
this uses vanilla js code to connect to a bot account and listen for events. a normal user uses a websocket as well, but the format is way different
!(function () {
if (null != window.WebSocket) {
if (
(function (n) {
try {
var e = localStorage.getItem(n);
return null == e ? null : JSON.parse(e);
} catch (n) {
return null;
}
})('token') &&
!window.__OVERLAY__
) {
var n = null != window.DiscordNative || null != window.require ? 'etf' : 'json',
e =
window.GLOBAL_ENV.GATEWAY_ENDPOINT +
'/?encoding=' +
n +
'&v=' +
window.GLOBAL_ENV.API_VERSION +
'&compress=zlib-stream';
console.log('[FAST CONNECT] connecting to: ' + e);
var o = new WebSocket(e);
o.binaryType = 'arraybuffer';
var t = Date.now(),
i = { open: !1, identify: !1, gateway: e, messages: [] };
(o.onopen = function () {
console.log('[FAST CONNECT] connected in ' + (Date.now() - t) + 'ms'), (i.open = !0);
}),
(o.onclose = o.onerror =
function () {
window._ws = null;
}),
(o.onmessage = function (n) {
i.messages.push(n);
}),
(window._ws = { ws: o, state: i });
}
}
})();
(got from discord.com)
as you can see, window._ws
is the websocket, and I need to somehow overwrite it before it connects
from chriseric1.github.io.
bf41583d33a683460193.js.zip
This is what I did in the new branch to patch for a newer client last year.
from chriseric1.github.io.
I don't even know what to look for in a 22mb file
from chriseric1.github.io.
I don't even know what to look for in a 22mb file
Look at the DIFF file, it has what is needed to log in to discord as a bot for newer clients, the other files are for reference. You need to also (as shown in diff) change bot=true to make it false by force
from chriseric1.github.io.
ok, how can I implement these changes at runtime? as I said I'm trying to make it work on discord.com
from chriseric1.github.io.
ok, how can I implement these changes at runtime? as I said I'm trying to make it work on discord.com
How are you going to inject it? Via F12 console, extensions, what? You also need to load the patches in time, before discord client logs off the bot to the login screen, because if it sees "bot == true" then it will, unless patched
from chriseric1.github.io.
ok, how can I implement these changes at runtime? as I said I'm trying to make it work on discord.com
How are you going to inject it? Via F12 console, extensions, what? You also need to load the patches in time, before discord client logs off the bot to the login screen, because if it sees "bot == true" then it will, unless patched
If you look at this sites source, the asset is injected before loading the page (
Line 48 in 7178544
ChrisEric1.GitHub.io/LCP.DBC.html
Line 48 in 7178544
from chriseric1.github.io.
This happens all the time and every time I enter the page
from chriseric1.github.io.
Related Issues (20)
- the download HOT 2
- Can't Message HOT 6
- Hello I can't seem to join other discord servers while being logged onto a bot. Is there a fix? HOT 1
- can't view or send messages, some buttons don't work properly. HOT 2
- the servers wont load HOT 6
- Redirects to login page HOT 2
- bot client not loading HOT 12
- i don't see any others server emojis anymore HOT 2
- Cant see messages just names HOT 3
- Error loading token bot why HOT 2
- extention issue HOT 2
- Messages will not load HOT 3
- whats happenn HOT 30
- Connection Error HOT 6
- Problem with displaying messages HOT 3
- Question: Do you log tokens? HOT 19
- Changing the bot's status seem to doesn't work HOT 4
- It is not showing message of people HOT 6
- I can't see messages HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chriseric1.github.io.