feat: drop self-bot support
This commit is contained in:
parent
2422866a3b
commit
472c7e33f8
4 changed files with 11 additions and 104 deletions
|
@ -220,20 +220,18 @@ class Gateway {
|
|||
}
|
||||
|
||||
private async sendIdentify(forceNewSession?: boolean): Promise<void> {
|
||||
if (this.client.bot === true) {
|
||||
this.debug('Fetching /gateway/bot...')
|
||||
const info = await this.client.rest.get(GATEWAY_BOT())
|
||||
if (info.session_start_limit.remaining === 0)
|
||||
throw new Error(
|
||||
`Session Limit Reached. Retry After ${info.session_start_limit.reset_after}ms`
|
||||
)
|
||||
this.debug(`Recommended Shards: ${info.shards}`)
|
||||
this.debug('=== Session Limit Info ===')
|
||||
this.debug(
|
||||
`Remaining: ${info.session_start_limit.remaining}/${info.session_start_limit.total}`
|
||||
this.debug('Fetching /gateway/bot...')
|
||||
const info = await this.client.rest.get(GATEWAY_BOT())
|
||||
if (info.session_start_limit.remaining === 0)
|
||||
throw new Error(
|
||||
`Session Limit Reached. Retry After ${info.session_start_limit.reset_after}ms`
|
||||
)
|
||||
this.debug(`Reset After: ${info.session_start_limit.reset_after}ms`)
|
||||
} else this.debug('Skipping /gateway/bot because bot: false')
|
||||
this.debug(`Recommended Shards: ${info.shards}`)
|
||||
this.debug('=== Session Limit Info ===')
|
||||
this.debug(
|
||||
`Remaining: ${info.session_start_limit.remaining}/${info.session_start_limit.total}`
|
||||
)
|
||||
this.debug(`Reset After: ${info.session_start_limit.reset_after}ms`)
|
||||
|
||||
if (forceNewSession === undefined || !forceNewSession) {
|
||||
const sessionIDCached = await this.cache.get('session_id')
|
||||
|
@ -260,19 +258,6 @@ class Gateway {
|
|||
presence: this.client.presence.create()
|
||||
}
|
||||
|
||||
if (this.client.bot === false) {
|
||||
this.debug('Modify Identify Payload for Self-bot..')
|
||||
delete payload.intents
|
||||
payload.presence = undefined
|
||||
payload.properties = {
|
||||
$os: 'windows',
|
||||
$browser: 'Firefox',
|
||||
$device: '',
|
||||
$referrer: '',
|
||||
$referring_domain: ''
|
||||
}
|
||||
}
|
||||
|
||||
this.debug('Sending Identify payload...')
|
||||
this.send({
|
||||
op: GatewayOpcodes.IDENTIFY,
|
||||
|
|
|
@ -24,8 +24,6 @@ export interface ClientOptions {
|
|||
forceNewSession?: boolean
|
||||
/** Startup presence of client */
|
||||
presence?: ClientPresence | ClientActivity | ActivityGame
|
||||
/** Whether it's a bot user or not? Use this if selfbot! */
|
||||
bot?: boolean
|
||||
/** Force all requests to Canary API */
|
||||
canary?: boolean
|
||||
/** Time till which Messages are to be cached, in MS. Default is 3600000 */
|
||||
|
@ -68,8 +66,6 @@ export class Client extends EventEmitter {
|
|||
channels: ChannelsManager = new ChannelsManager(this)
|
||||
emojis: EmojisManager = new EmojisManager(this)
|
||||
|
||||
/** Whether this client will login as bot user or not */
|
||||
bot: boolean = true
|
||||
/** Whether the REST Manager will use Canary API or not */
|
||||
canary: boolean = false
|
||||
/** Client's presence. Startup one if set before connecting */
|
||||
|
@ -98,7 +94,6 @@ export class Client extends EventEmitter {
|
|||
options.presence instanceof ClientPresence
|
||||
? options.presence
|
||||
: new ClientPresence(options.presence)
|
||||
if (options.bot === false) this.bot = false
|
||||
if (options.canary === true) this.canary = true
|
||||
if (options.messageCacheLifetime !== undefined)
|
||||
this.messageCacheLifetime = options.messageCacheLifetime
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as baseEndpoints from '../consts/urlsAndVersions.ts'
|
||||
import { Client } from './client.ts'
|
||||
import { getBuildInfo } from '../utils/buildInfo.ts'
|
||||
import { Collection } from '../utils/collection.ts'
|
||||
|
||||
export type RequestMethods =
|
||||
|
@ -171,24 +170,6 @@ export class RESTManager {
|
|||
method: method.toUpperCase()
|
||||
}
|
||||
|
||||
if (this.client?.bot === false) {
|
||||
// This is a selfbot. Use requests similar to Discord Client
|
||||
data.headers.authorization = this.client.token as string
|
||||
data.headers['accept-language'] = 'en-US'
|
||||
data.headers.accept = '*/*'
|
||||
data.headers['sec-fetch-dest'] = 'empty'
|
||||
data.headers['sec-fetch-mode'] = 'cors'
|
||||
data.headers['sec-fetch-site'] = 'same-origin'
|
||||
data.headers['x-super-properties'] = btoa(
|
||||
JSON.stringify(getBuildInfo(this.client))
|
||||
)
|
||||
delete data.headers['User-Agent']
|
||||
delete data.headers.Authorization
|
||||
headers.credentials = 'include'
|
||||
headers.mode = 'cors'
|
||||
headers.referrerPolicy = 'no-referrer-when-downgrade'
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Client } from '../models/client.ts'
|
||||
|
||||
/** Gets Discord Build info for self-bot support */
|
||||
export const getBuildInfo = (
|
||||
client: Client
|
||||
): {
|
||||
os: string
|
||||
os_version: string
|
||||
browser: string
|
||||
browser_version: string
|
||||
browser_user_agent: string
|
||||
client_build_number: number
|
||||
client_event_source: null
|
||||
release_channel: string
|
||||
} => {
|
||||
let os = 'Windows'
|
||||
let os_version = '10'
|
||||
let client_build_number = 71073
|
||||
const client_event_source = null
|
||||
let release_channel = 'stable'
|
||||
if (client.canary === true) {
|
||||
release_channel = 'canary'
|
||||
client_build_number = 71076
|
||||
}
|
||||
let browser = 'Firefox'
|
||||
let 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
|
||||
// TODO: Use current OS properties, but also browser_user_agent accordingly
|
||||
if (Deno.build.os === 'darwin') {
|
||||
os = 'MacOS'
|
||||
os_version = '10.15.6'
|
||||
browser = 'Firefox'
|
||||
browser_version = '14.0.1'
|
||||
browser_user_agent =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15'
|
||||
}
|
||||
// else if (Deno.build.os === 'linux') os = 'Ubuntu'
|
||||
|
||||
return {
|
||||
os,
|
||||
os_version,
|
||||
browser,
|
||||
browser_version,
|
||||
browser_user_agent,
|
||||
client_build_number,
|
||||
client_event_source,
|
||||
release_channel
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue