discord-slim
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -8,3 +8,3 @@ "use strict"; | ||
exports.Host = 'https://discord.com', exports.API = 'https://discord.com/api', exports.CDN = 'https://cdn.discordapp.com'; | ||
const STANDARD_TIMEOUT = 1000, REQUEST_RETRY_COUNT = 5; | ||
const STANDARD_TIMEOUT = 1000, REQUEST_RETRY_COUNT = 5, API_VERSION = 6, API_PATH = `${exports.API}/v${API_VERSION}`; | ||
var OPCode; | ||
@@ -35,9 +35,8 @@ (function (OPCode) { | ||
} | ||
const response = await SafePromise(HttpsRequest(`${exports.API}/gateway/bot`, { headers: { Authorization: this.#auth } })); | ||
const response = await SafePromise(this.Request('GET', '/gateway/bot')); | ||
if (!response) | ||
return this.emit('fatal', 'Unable to retrieve a gateway.'); | ||
const gateway = SafeJsonParse(response.data); | ||
if (!(gateway && (typeof gateway.url == 'string'))) | ||
if (typeof response.url != 'string') | ||
return this.emit('fatal', 'Unexpected gateway API response.'); | ||
this.#ws = new WebSocket(gateway.url); | ||
this.#ws = new WebSocket(`${response.url}?v=${API_VERSION}`); | ||
this.#ws.on('message', this.#OnMessage); | ||
@@ -110,3 +109,2 @@ this.#ws.on('close', this.#OnClose); | ||
properties: { $os: 'linux', $browser: 'bot', $device: 'bot' }, | ||
version: 6, | ||
intents: this.#intents, | ||
@@ -187,3 +185,3 @@ }, | ||
throw 'Route must be a string.'; | ||
const url = `${exports.API}${route}`; | ||
const url = API_PATH + route; | ||
if ((auth != null) && (typeof auth != 'string')) | ||
@@ -232,3 +230,3 @@ throw 'Auth must be a string.'; | ||
else { | ||
RequestError({ code, message: response.message || response.error || '' }); | ||
RequestError({ code, message: response?.message || response?.error || '' }); | ||
} | ||
@@ -235,0 +233,0 @@ } |
{ | ||
"name": "discord-slim", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Lightweight Discord client for Node.js.", | ||
@@ -5,0 +5,0 @@ "author": "Hanabishi", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43064
876