🐛 fix identify default intent
This commit is contained in:
parent
12dbaf78de
commit
61d85d04ae
21
client.js
21
client.js
@ -2,7 +2,8 @@ require("missing-native-js-functions");
|
|||||||
const WebSocket = require("ws");
|
const WebSocket = require("ws");
|
||||||
const Constants = require("./dist/util/Constants");
|
const Constants = require("./dist/util/Constants");
|
||||||
|
|
||||||
const ws = new WebSocket("ws://127.0.0.1:8080");
|
// const ws = new WebSocket("ws://127.0.0.1:8080");
|
||||||
|
const ws = new WebSocket("wss://gateway.discord.gg");
|
||||||
|
|
||||||
ws.on("open", () => {
|
ws.on("open", () => {
|
||||||
// ws.send(JSON.stringify({ req_type: "new_auth" }));
|
// ws.send(JSON.stringify({ req_type: "new_auth" }));
|
||||||
@ -27,14 +28,18 @@ ws.on("message", (buffer) => {
|
|||||||
send({ op: 1 });
|
send({ op: 1 });
|
||||||
}, data.d.heartbeat_interval);
|
}, data.d.heartbeat_interval);
|
||||||
|
|
||||||
|
// send({
|
||||||
|
// op: 2,
|
||||||
|
// d: {
|
||||||
|
// token:
|
||||||
|
// "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMTY0MjkxNzQzMjA2NjA0OCIsImlhdCI6MTYxMzU4MTE1MX0.7Qj_z2lYIgJ0rc7NfGtpW5DKGqecQfv1mLpoBUQHKDc",
|
||||||
|
// intents: 0n,
|
||||||
|
// properties: {},
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
send({
|
send({
|
||||||
op: 2,
|
op: 6,
|
||||||
d: {
|
|
||||||
token:
|
|
||||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMTY0MjkxNzQzMjA2NjA0OCIsImlhdCI6MTYxMzU4MTE1MX0.7Qj_z2lYIgJ0rc7NfGtpW5DKGqecQfv1mLpoBUQHKDc",
|
|
||||||
intents: 0n,
|
|
||||||
properties: {},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
MemberModel,
|
MemberModel,
|
||||||
ReadyEventData,
|
ReadyEventData,
|
||||||
UserModel,
|
UserModel,
|
||||||
|
toObject,
|
||||||
} from "fosscord-server-util";
|
} from "fosscord-server-util";
|
||||||
import { setupListener } from "../listener/listener";
|
import { setupListener } from "../listener/listener";
|
||||||
import { instanceOf } from "lambert-server";
|
import { instanceOf } from "lambert-server";
|
||||||
@ -31,13 +32,14 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
try {
|
try {
|
||||||
var decoded = await checkToken(identify.token); // will throw an error if invalid
|
var decoded = await checkToken(identify.token); // will throw an error if invalid
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error("invalid token", error);
|
||||||
return this.close(CLOSECODES.Authentication_failed);
|
return this.close(CLOSECODES.Authentication_failed);
|
||||||
}
|
}
|
||||||
this.user_id = decoded.id;
|
this.user_id = decoded.id;
|
||||||
if (!identify.intents) identify.intents = BigInt("11111111111111");
|
if (!identify.intents) identify.intents = 0b11111111111111n;
|
||||||
this.intents = new Intents(identify.intents);
|
this.intents = new Intents(identify.intents);
|
||||||
|
|
||||||
const members = await MemberModel.find({ id: this.user_id }).lean().exec();
|
const members = toObject(await MemberModel.find({ id: this.user_id }).exec());
|
||||||
const merged_members = members.map((x: any) => {
|
const merged_members = members.map((x: any) => {
|
||||||
const y = { ...x, user_id: x.id };
|
const y = { ...x, user_id: x.id };
|
||||||
delete y.settings;
|
delete y.settings;
|
||||||
@ -64,7 +66,6 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
.populate("roles")
|
.populate("roles")
|
||||||
.populate("emojis")
|
.populate("emojis")
|
||||||
.populate({ path: "joined_at", match: { id: this.user_id } })
|
.populate({ path: "joined_at", match: { id: this.user_id } })
|
||||||
.lean()
|
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
const privateUser = {
|
const privateUser = {
|
||||||
@ -91,7 +92,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
|||||||
user: privateUser,
|
user: privateUser,
|
||||||
user_settings: user.user_settings,
|
user_settings: user.user_settings,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
guilds: guilds.map((x) => {
|
guilds: toObject(guilds).map((x) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
x.guild_hashes = {
|
x.guild_hashes = {
|
||||||
channels: { omitted: false, hash: "y4PV2fZ0gmo" },
|
channels: { omitted: false, hash: "y4PV2fZ0gmo" },
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "ES6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
||||||
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
||||||
"lib": ["ES2015", "DOM"] /* Specify library files to be included in the compilation. */,
|
"lib": ["ES2015", "ES2020.BigInt", "DOM"] /* Specify library files to be included in the compilation. */,
|
||||||
"allowJs": true /* Allow javascript files to be compiled. */,
|
"allowJs": true /* Allow javascript files to be compiled. */,
|
||||||
"checkJs": true /* Report errors in .js files. */,
|
"checkJs": true /* Report errors in .js files. */,
|
||||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user