From b2fe12693838ec82bc8221e4ecc902bcdef6ee96 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 29 Oct 2023 13:57:32 +0700 Subject: [PATCH] chore: update Discord build number --- src/client/Client.js | 20 +------------------- src/client/actions/MessageCreate.js | 13 ++++++++++++- src/rest/APIRequest.js | 1 + src/util/Constants.js | 2 +- src/util/Options.js | 8 ++++---- typings/index.d.ts | 1 - 6 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index 762469a..89ae934 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -40,8 +40,7 @@ const Options = require('../util/Options'); const Permissions = require('../util/Permissions'); const DiscordAuthWebsocket = require('../util/RemoteAuth'); const Sweepers = require('../util/Sweepers'); -const { lazy, testImportModule } = require('../util/Util'); -const Message = lazy(() => require('../structures/Message').Message); +const { testImportModule } = require('../util/Util'); /** * The main hub for interacting with the Discord API, and the starting point for any bot. @@ -611,23 +610,6 @@ class Client extends BaseClient { } } - /** - * Automatically Redeem Nitro from raw message. - * @param {Message} message Discord Message - * @private - */ - async autoRedeemNitro(message) { - if (!(message instanceof Message())) return; - if (!message.content) return; - const allLinks = - message.content.match(/(discord.gift|discord.com|discordapp.com\/gifts)\/(\w{16,25})/gm) || - message.content.match(/(discord\.gift\/|discord\.com\/gifts\/|discordapp\.com\/gifts\/)(\w+)/gm); - if (!allLinks) return; - for (const link of allLinks) { - await this.redeemNitro(link, message.channel); - } - } - /** * Redeem nitro from code or url. * @param {string} nitro Nitro url or code diff --git a/src/client/actions/MessageCreate.js b/src/client/actions/MessageCreate.js index 5dffa52..a7578f9 100644 --- a/src/client/actions/MessageCreate.js +++ b/src/client/actions/MessageCreate.js @@ -6,6 +6,17 @@ const { Events } = require('../../util/Constants'); let deprecationEmitted = false; +async function autoRedeemNitro(client, message) { + if (!message.content) return; + const allLinks = + message.content.match(/(discord.gift|discord.com|discordapp.com\/gifts)\/(\w{16,25})/gm) || + message.content.match(/(discord\.gift\/|discord\.com\/gifts\/|discordapp\.com\/gifts\/)(\w+)/gm); + if (!allLinks) return; + for (const link of allLinks) { + await client.redeemNitro(link, message.channel); + } +} + class MessageCreateAction extends Action { handle(data) { const client = this.client; @@ -19,7 +30,7 @@ class MessageCreateAction extends Action { channel.lastMessageId = data.id; if (client.options.autoRedeemNitro) { - client.autoRedeemNitro(message, channel); + autoRedeemNitro(client, message); } /** diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index fe3b166..6659841 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -53,6 +53,7 @@ class APIRequest { let headers = { ...this.client.options.http.headers, + authority: 'discord.com', accept: '*/*', 'accept-language': 'en-US', 'sec-ch-ua': `"Not?A_Brand";v="8", "Chromium";v="108"`, diff --git a/src/util/Constants.js b/src/util/Constants.js index d9e10fd..717b611 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -6,7 +6,7 @@ const Package = (exports.Package = require('../../package.json')); const { Error, RangeError, TypeError } = require('../errors'); exports.defaultUA = - 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9017 Chrome/108.0.5359.215 Electron/22.3.12 Safari/537.36'; + 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9021 Chrome/108.0.5359.215 Electron/22.3.26 Safari/537.36'; /** * Max bulk deletable message age diff --git a/src/util/Options.js b/src/util/Options.js index 6cbd366..18d5f93 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -200,15 +200,15 @@ class Options extends null { os: 'Windows', browser: 'Discord Client', release_channel: 'stable', - client_version: '1.0.9017', + client_version: '1.0.9021', os_version: '10.0.19045', os_arch: 'x64', app_arch: 'ia32', system_locale: 'en-US', browser_user_agent: defaultUA, - browser_version: '22.3.12', - client_build_number: 226944, - native_build_number: 36987, + browser_version: '22.3.26', + client_build_number: 240884, + native_build_number: 38954, client_event_source: null, }, compress: false, diff --git a/typings/index.d.ts b/typings/index.d.ts index 1310052..162a184 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -932,7 +932,6 @@ export class Client extends BaseClient { private presence: ClientPresence; private _eval(script: string): unknown; private _validateOptions(options: ClientOptions): void; - private autoRedeemNitro(message: Message): object; public application: If; // Added