diff --git a/DOCUMENT.md b/DOCUMENT.md index b66c221..00e3865 100644 --- a/DOCUMENT.md +++ b/DOCUMENT.md @@ -228,6 +228,15 @@ You can cache to use these files, do not run this function too much because it w And you can change the status 5 times every 20 seconds! +## Interaction +
+Button Click (v1) + +```js +await Button.click(Message); +``` +
+ ## More features
diff --git a/package.json b/package.json index e16df60..c7fb3e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord.js-selfbot-v13", - "version": "1.0.2", + "version": "1.0.3", "description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]", "main": "./src/index.js", "types": "./typings/index.d.ts", diff --git a/src/errors/Messages.js b/src/errors/Messages.js index 2823ed6..a3695d5 100644 --- a/src/errors/Messages.js +++ b/src/errors/Messages.js @@ -154,7 +154,7 @@ const Messages = { SWEEP_FILTER_RETURN: 'The return value of the sweepFilter function was not false or a Function', - INVALID_BOT_METHOD: `Bot accounts cannot use this method`, + INVALID_BOT_METHOD: `Bot accounts cannot use this method`, INVALID_USER_METHOD: `User accounts cannot use this method`, INVALID_LOCALE: 'Unable to select this location', FOLDER_NOT_FOUND: 'Server directory not found', diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index 9136752..904a223 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -30,6 +30,22 @@ class ClientUser extends User { } if ('token' in data) this.client.token = data.token; + + // Add (Selfbot) + if ('premium' in data) this.nitro = data.premium; + /** + * Nitro Status + * `0`: None + * `1`: Classic + * `2`: Boost + * @external + * https://discord.com/developers/docs/resources/user#user-object-premium-types + * @type {Number} + */ + if ('purchased_flags' in data) this.nitroType = data.purchased_flags; + if ('phone' in data) this.phoneNumber = data.phone; + if ('nsfw_allowed' in data) this.nsfwAllowed = data.nsfw_allowed; + if ('email' in data) this.emailAddress = data.email; } /** diff --git a/src/structures/MessageButton.js b/src/structures/MessageButton.js index a94c1ec..ddf8e4e 100644 --- a/src/structures/MessageButton.js +++ b/src/structures/MessageButton.js @@ -1,6 +1,7 @@ 'use strict'; const BaseMessageComponent = require('./BaseMessageComponent'); +const { Message } = require('./Message'); const { RangeError } = require('../errors'); const { MessageButtonStyles, MessageComponentTypes } = require('../util/Constants'); const Util = require('../util/Util'); @@ -160,6 +161,32 @@ class MessageButton extends BaseMessageComponent { static resolveStyle(style) { return typeof style === 'string' ? style : MessageButtonStyles[style]; } + // Patch Click + /** + * Click the button + * @param {Message} message Discord Message + * @returns true if the button is clicked + */ + async click(message) { + if (!message instanceof Message) throw new Error("[UNKNOWN_MESSAGE] Please pass a valid Message"); + await message.client.api.interactions.post( + { + data: { + type: 3, // ? + guild_id: message.guild?.id ?? null, // In DMs + channel_id: message.channel.id, + message_id: message.id, + application_id: message.author.id, + session_id: message.client.session_id, + data: { + component_type: 2, // Button + custom_id: this.customId + }, + } + } + ) + return true; + } } module.exports = MessageButton; diff --git a/src/util/Options.js b/src/util/Options.js index 4a3c9cc..f7f9af9 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -142,58 +142,65 @@ class Options extends null { messageSweepInterval: 0, invalidRequestWarningInterval: 0, intents: 65535, - partials: [], + partials: [ + 'USER', + 'CHANNEL', + 'GUILD_MEMBER', + 'MESSAGE', + 'REACTION', + 'GUILD_SCHEDULED_EVENT', + ], // Enable the partials restWsBridgeTimeout: 5_000, restRequestTimeout: 15_000, restGlobalRateLimit: 0, retryLimit: 1, restTimeOffset: 500, restSweepInterval: 60, - failIfNotExists: true, + failIfNotExists: false, userAgentSuffix: [], presence: {}, sweepers: {}, ws: { - large_threshold: 50, - compress: false, - properties: { - //$os: 'iPhone14,5', - //$browser: 'Discord iOS', - //$device: 'iPhone14,5 OS 15.2', + large_threshold: 50, + compress: false, + properties: { + //$os: 'iPhone14,5', + //$browser: 'Discord iOS', + //$device: 'iPhone14,5 OS 15.2', $os: 'Windows 11', $browser: 'Chrome', $device: 'ASUS ROG Phone 5', - }, - version: 10, - }, - http: { - headers: { - Accept: '*/*', - // 'Accept-Encoding': 'gzip, deflate, br', - 'Accept-Language': 'en-US,en;q=0.9', - 'Cache-Control': 'no-cache', + }, + version: 10, + }, + http: { + headers: { + Accept: '*/*', + // 'Accept-Encoding': 'gzip, deflate, br', + 'Accept-Language': 'en-US,en;q=0.9', + 'Cache-Control': 'no-cache', // 'Content-Type': 'application/json', - Pragma: 'no-cache', - Referer: 'https://discord.com/channels/@me', - 'Sec-Ch-Ua': '" Not A;Brand";v="99" "', - 'Sec-Ch-Ua-Mobile': '?0', - 'Sec-Ch-Ua-Platform': '"iOS"', - 'Sec-Fetch-Dest': 'empty', - 'Sec-Fetch-Mode': 'cors', - 'Sec-Fetch-Site': 'same-origin', - 'X-Debug-Options': 'bugReporterEnabled', - 'X-Discord-Locale': 'en-US', - Origin: 'https://discord.com', + Pragma: 'no-cache', + Referer: 'https://discord.com/channels/@me', + 'Sec-Ch-Ua': '" Not A;Brand";v="99" "', + 'Sec-Ch-Ua-Mobile': '?0', + 'Sec-Ch-Ua-Platform': '"iOS"', + 'Sec-Fetch-Dest': 'empty', + 'Sec-Fetch-Mode': 'cors', + 'Sec-Fetch-Site': 'same-origin', + 'X-Debug-Options': 'bugReporterEnabled', + 'X-Discord-Locale': 'en-US', + Origin: 'https://discord.com', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36', - }, - agent: {}, - version: 10, - api: 'https://discord.com/api', - cdn: 'https://cdn.discordapp.com', - invite: 'https://discord.gg', - template: 'https://discord.new', - scheduledEvent: 'https://discord.com/events', - }, + }, + agent: {}, + version: 10, + api: 'https://discord.com/api', + cdn: 'https://cdn.discordapp.com', + invite: 'https://discord.gg', + template: 'https://discord.new', + scheduledEvent: 'https://discord.com/events', + }, }; } diff --git a/typings/index.d.ts b/typings/index.d.ts index 8990f3e..88d5e8f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -633,8 +633,23 @@ export class ClientUser extends User { public setPresence(data: PresenceData): ClientPresence; public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence; public setUsername(username: string): Promise; + // Selfbot + public readonly nitro: boolean; + /** + * Nitro Status + * `0`: None + * `1`: Classic + * `2`: Boost + * @external + * https://discord.com/developers/docs/resources/user#user-object-premium-types + * @type {Number} + */ + public readonly nitroType: NitroType; + public readonly phoneNumber: String; + public readonly nsfwAllowed: boolean; + public readonly emailAddress: String; } - +type NitroType = 0 | 1 | 2; export class Options extends null { private constructor(); public static defaultMakeCacheSettings: CacheWithLimitsOptions; @@ -1615,6 +1630,7 @@ export class MessageButton extends BaseMessageComponent { public setStyle(style: MessageButtonStyleResolvable): this; public setURL(url: string): this; public toJSON(): APIButtonComponent; + public click(message): Promise; private static resolveStyle(style: MessageButtonStyleResolvable): MessageButtonStyle; }