Fix lint (2)
This commit is contained in:
parent
7ead2c2ea6
commit
2f560d72e7
6 changed files with 36 additions and 26 deletions
|
@ -16,23 +16,23 @@ client.on("messageCreate", (msg: Message) => {
|
||||||
console.log("discord.deno - ping example");
|
console.log("discord.deno - ping example");
|
||||||
|
|
||||||
const token = prompt("Input Bot Token:");
|
const token = prompt("Input Bot Token:");
|
||||||
if (!token) {
|
if (token === null) {
|
||||||
console.log("No token provided");
|
console.log("No token provided");
|
||||||
Deno.exit();
|
Deno.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
const intents = prompt("Input Intents (0 = All, 1 = Presence, 2 = Server Members, 3 = None):");
|
const intents = prompt("Input Intents (0 = All, 1 = Presence, 2 = Server Members, 3 = None):");
|
||||||
if (!intents || !["0", "1", "2", "3"].includes(intents)) {
|
if (intents === null || !["0", "1", "2", "3"].includes(intents)) {
|
||||||
console.log("No intents provided");
|
console.log("No intents provided");
|
||||||
Deno.exit();
|
Deno.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
let ints;
|
let ints;
|
||||||
if (intents == "0") {
|
if (intents === "0") {
|
||||||
ints = Intents.All;
|
ints = Intents.All;
|
||||||
} else if (intents == "1") {
|
} else if (intents === "1") {
|
||||||
ints = Intents.Presence;
|
ints = Intents.Presence;
|
||||||
} else if (intents == "2") {
|
} else if (intents === "2") {
|
||||||
ints = Intents.GuildMembers;
|
ints = Intents.GuildMembers;
|
||||||
} else {
|
} else {
|
||||||
ints = Intents.None;
|
ints = Intents.None;
|
||||||
|
|
|
@ -213,7 +213,7 @@ class Gateway {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let payload: any = {
|
const payload: any = {
|
||||||
op: GatewayOpcodes.IDENTIFY,
|
op: GatewayOpcodes.IDENTIFY,
|
||||||
d: {
|
d: {
|
||||||
token: this.token,
|
token: this.token,
|
||||||
|
@ -315,7 +315,7 @@ class Gateway {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
sendHeartbeat() {
|
sendHeartbeat(): void {
|
||||||
const payload = {
|
const payload = {
|
||||||
op: GatewayOpcodes.HEARTBEAT,
|
op: GatewayOpcodes.HEARTBEAT,
|
||||||
d: this.sequenceID ?? null
|
d: this.sequenceID ?? null
|
||||||
|
@ -325,7 +325,7 @@ class Gateway {
|
||||||
this.lastPingTimestamp = Date.now()
|
this.lastPingTimestamp = Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
heartbeat() {
|
heartbeat(): void {
|
||||||
if (this.heartbeatServerResponded) {
|
if (this.heartbeatServerResponded) {
|
||||||
this.heartbeatServerResponded = false
|
this.heartbeatServerResponded = false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Collection } from '../utils/collection.ts'
|
import { Collection } from '../utils/collection.ts'
|
||||||
import { Client } from './client.ts'
|
|
||||||
import {
|
import {
|
||||||
connect,
|
connect,
|
||||||
Redis,
|
Redis,
|
||||||
|
|
|
@ -176,7 +176,7 @@ export class RESTManager {
|
||||||
headers['Content-Type'] = 'application/json'
|
headers['Content-Type'] = 'application/json'
|
||||||
}
|
}
|
||||||
|
|
||||||
let data: { [name: string]: any } = {
|
const data: { [name: string]: any } = {
|
||||||
headers,
|
headers,
|
||||||
body: body?.file ?? JSON.stringify(body),
|
body: body?.file ?? JSON.stringify(body),
|
||||||
method: method.toUpperCase()
|
method: method.toUpperCase()
|
||||||
|
@ -184,18 +184,18 @@ export class RESTManager {
|
||||||
|
|
||||||
if (this.client.bot === false) {
|
if (this.client.bot === false) {
|
||||||
// This is a selfbot. Use requests similar to Discord Client
|
// This is a selfbot. Use requests similar to Discord Client
|
||||||
data.headers['authorization'] = this.client.token as string
|
data.headers.authorization = this.client.token as string
|
||||||
data.headers['accept-language'] = 'en-US'
|
data.headers['accept-language'] = 'en-US'
|
||||||
data.headers['accept'] = '*/*'
|
data.headers.accept = '*/*'
|
||||||
data.headers['sec-fetch-dest'] = 'empty'
|
data.headers['sec-fetch-dest'] = 'empty'
|
||||||
data.headers['sec-fetch-mode'] = 'cors'
|
data.headers['sec-fetch-mode'] = 'cors'
|
||||||
data.headers['sec-fetch-site'] = 'same-origin'
|
data.headers['sec-fetch-site'] = 'same-origin'
|
||||||
data.headers['x-super-properties'] = btoa(JSON.stringify(getBuildInfo(this.client)))
|
data.headers['x-super-properties'] = btoa(JSON.stringify(getBuildInfo(this.client)))
|
||||||
delete data.headers['User-Agent']
|
delete data.headers['User-Agent']
|
||||||
delete data.headers['Authorization']
|
delete data.headers.Authorization
|
||||||
headers['credentials'] = 'include'
|
headers.credentials = 'include'
|
||||||
headers['mode'] = 'cors'
|
headers.mode = 'cors'
|
||||||
headers['referrerPolicy'] = 'no-referrer-when-downgrade'
|
headers.referrerPolicy = 'no-referrer-when-downgrade'
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
@ -252,8 +252,8 @@ export class RESTManager {
|
||||||
let urlToUse =
|
let urlToUse =
|
||||||
method === 'get' && query !== '' ? `${url}?${query}` : url
|
method === 'get' && query !== '' ? `${url}?${query}` : url
|
||||||
|
|
||||||
if (this.client.canary) {
|
if (this.client.canary === true) {
|
||||||
let split = urlToUse.split('//')
|
const split = urlToUse.split('//')
|
||||||
urlToUse = split[0] + '//canary.' + split[1]
|
urlToUse = split[0] + '//canary.' + split[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,28 @@
|
||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
import { Client } from "../models/client.ts";
|
import { Client } from "../models/client.ts";
|
||||||
|
|
||||||
export const getBuildInfo = (client: Client) => {
|
export const getBuildInfo = (client: Client): {
|
||||||
let os = 'Windows'
|
os: string
|
||||||
let os_version = '10'
|
os_version: string
|
||||||
|
browser: string
|
||||||
|
browser_version: string
|
||||||
|
browser_user_agent: string
|
||||||
|
client_build_number: number
|
||||||
|
client_event_source: null
|
||||||
|
release_channel: string
|
||||||
|
} => {
|
||||||
|
const os = 'Windows'
|
||||||
|
const os_version = '10'
|
||||||
let client_build_number = 71073
|
let client_build_number = 71073
|
||||||
let client_event_source = null
|
const client_event_source = null
|
||||||
let release_channel = 'stable'
|
let release_channel = 'stable'
|
||||||
if (client.canary) {
|
if (client.canary === true) {
|
||||||
release_channel = 'canary'
|
release_channel = 'canary'
|
||||||
client_build_number = 71076
|
client_build_number = 71076
|
||||||
}
|
}
|
||||||
let browser = 'Firefox'
|
const browser = 'Firefox'
|
||||||
let browser_version = '83.0'
|
const browser_version = '83.0'
|
||||||
let browser_user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 ' + browser + '/' + browser_version
|
const browser_user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 ' + browser + '/' + browser_version
|
||||||
// TODO: Use current OS properties, but also browser_user_agent accordingly
|
// TODO: Use current OS properties, but also browser_user_agent accordingly
|
||||||
// if (Deno.build.os === 'darwin') os = 'MacOS'
|
// if (Deno.build.os === 'darwin') os = 'MacOS'
|
||||||
// else if (Deno.build.os === 'linux') os = 'Ubuntu'
|
// else if (Deno.build.os === 'linux') os = 'Ubuntu'
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { GatewayIntents } from "../types/gateway.ts";
|
import { GatewayIntents } from "../types/gateway.ts";
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
||||||
export class Intents {
|
export class Intents {
|
||||||
static All: number[] = [
|
static All: number[] = [
|
||||||
GatewayIntents.GUILD_MEMBERS,
|
GatewayIntents.GUILD_MEMBERS,
|
||||||
|
|
Loading…
Reference in a new issue