chore(release): version

This commit is contained in:
March 7th 2022-06-15 23:07:24 +07:00
parent d2a766ef3b
commit 007f0ef3b1
13 changed files with 173 additions and 72 deletions

File diff suppressed because one or more lines are too long

41
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "discord.js-selfbot-v13",
"version": "2.3.2",
"version": "2.3.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "discord.js-selfbot-v13",
"version": "2.3.2",
"version": "2.3.3",
"license": "GNU General Public License v3.0",
"dependencies": {
"@discordjs/builders": "^0.15.0",
@ -16,7 +16,6 @@
"@sapphire/snowflake": "^3.2.2",
"@types/node-fetch": "^2.6.1",
"@types/ws": "^8.5.3",
"ascii-table": "^0.0.9",
"axios": "^0.27.2",
"bignumber.js": "^9.0.2",
"bufferutil": "^4.0.6",
@ -24,9 +23,7 @@
"discord-api-types": "^0.34.0",
"discord-bettermarkdown": "^1.2.0",
"discord-rpc-contructor": "^1.1.5",
"discord.js": "^13.8.0",
"form-data": "^4.0.0",
"i": "^0.3.7",
"json-bigint": "^1.0.0",
"lodash": "^4.17.21",
"lodash.snakecase": "^4.1.1",
@ -35,7 +32,6 @@
"qrcode-terminal": "^0.12.0",
"safe-base64": "^2.0.1-0",
"string_decoder": "^1.3.0",
"string-similarity": "^4.0.4",
"utf-8-validate": "^5.0.9",
"ws": "^8.8.0"
},
@ -2964,11 +2960,6 @@
"node": ">=0.10.0"
}
},
"node_modules/ascii-table": {
"version": "0.0.9",
"resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
"integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
},
"node_modules/asn1": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz",
@ -6779,14 +6770,6 @@
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/i": {
"version": "0.3.7",
"resolved": "https://registry.npmjs.org/i/-/i-0.3.7.tgz",
"integrity": "sha512-FYz4wlXgkQwIPqhzC5TdNMLSE5+GS1IIDJZY/1ZiEPCT2S3COUVZeT5OW4BmW4r5LHLQuOosSwsvnroG9GR59Q==",
"engines": {
"node": ">=0.4"
}
},
"node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
@ -13176,11 +13159,6 @@
"node": ">=10"
}
},
"node_modules/string-similarity": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz",
"integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ=="
},
"node_modules/string-width": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
@ -17052,11 +17030,6 @@
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
"dev": true
},
"ascii-table": {
"version": "0.0.9",
"resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
"integrity": "sha1-BqZgTWpV1L9BqaR9mHLXp42jHnM="
},
"asn1": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz",
@ -20014,11 +19987,6 @@
"integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==",
"dev": true
},
"i": {
"version": "0.3.7",
"resolved": "https://registry.npmjs.org/i/-/i-0.3.7.tgz",
"integrity": "sha512-FYz4wlXgkQwIPqhzC5TdNMLSE5+GS1IIDJZY/1ZiEPCT2S3COUVZeT5OW4BmW4r5LHLQuOosSwsvnroG9GR59Q=="
},
"iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
@ -24627,11 +24595,6 @@
"strip-ansi": "^6.0.0"
}
},
"string-similarity": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz",
"integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ=="
},
"string-width": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "discord.js-selfbot-v13",
"version": "2.3.2",
"version": "2.3.3",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js",
"types": "./typings/index.d.ts",
@ -17,7 +17,7 @@
"lint:all": "npm run lint && npm run lint:typings",
"docs": "docgen --source src --custom docs/index.yml --output docs/main.json",
"docs:test": "docgen --source src --custom docs/index.yml",
"build": "npm run lint:fix && npm run lint:typings:fix && npm run format && npm run docs"
"build": "npm i && npm run lint:fix && npm run lint:typings:fix && npm run format && npm run docs"
},
"files": [
"src",
@ -58,7 +58,6 @@
"@sapphire/snowflake": "^3.2.2",
"@types/node-fetch": "^2.6.1",
"@types/ws": "^8.5.3",
"ascii-table": "^0.0.9",
"axios": "^0.27.2",
"bignumber.js": "^9.0.2",
"bufferutil": "^4.0.6",
@ -66,9 +65,7 @@
"discord-api-types": "^0.34.0",
"discord-bettermarkdown": "^1.2.0",
"discord-rpc-contructor": "^1.1.5",
"discord.js": "^13.8.0",
"form-data": "^4.0.0",
"i": "^0.3.7",
"json-bigint": "^1.0.0",
"lodash": "^4.17.21",
"lodash.snakecase": "^4.1.1",
@ -77,7 +74,6 @@
"qrcode-terminal": "^0.12.0",
"safe-base64": "^2.0.1-0",
"string_decoder": "^1.3.0",
"string-similarity": "^4.0.4",
"utf-8-validate": "^5.0.9",
"ws": "^8.8.0"
},

View File

@ -0,0 +1,23 @@
'use strict';
const { Events } = require('../../../util/Constants');
module.exports = (client, { d: data }) => {
/**
* @typedef {object} AutocompleteResponseChoice
* @property {string} name The name of the choice
* @property {string} value The value of the choice
*/
/**
* @typedef {object} AutocompleteResponse
* @property {Snowflake} [nonce] Snowflake of the data
* @property {Array<AutocompleteResponseChoice>} [choices] Array of choices
*/
/**
* Emitted when receiving a response from Discord
* @event Client#applicationCommandAutocompleteResponse
* @param {AutocompleteResponse} data Data
* @deprecated Test only
*/
client.emit(Events.DEBUG, data);
};

View File

@ -2,5 +2,10 @@
const { Events } = require('../../../util/Constants');
module.exports = (client, { d: data }) => {
/**
* Emitted whenever client user send interaction and success
* @event Client#interactionSuccess
* @param {InteractionResponseBody} data data
*/
client.emit(Events.INTERACTION_SUCCESS, data);
};

View File

@ -241,6 +241,76 @@ class MessageManager extends CachedManager {
for (const message of data) messages.set(message.id, this._add(message, cache));
return messages;
}
/**
* @typedef {object} MessageSearchOptions
* @property {Array<Snowflake>} [author] An array of author IDs to filter by
* @property {Array<Snowflake>} [mentions] An array of user IDs (mentioned) to filter by
* @property {string} [content] A messageContent to filter by
* @property {Snowflake} [maxId] The maximum Message ID to filter by
* @property {Snowflake} [minId] The minimum Message ID to filter by
* @property {Array<Snowflake>} [channel] An array of channel IDs to filter by
* @property {boolean} [pinned] Whether to filter by pinned messages
* @property {Array<string>} [has] Message has: `link`, `embed`, `file`, `video`, `image`, or `sound`
*/
/**
* @typedef {object} MessageSearchResult
* @property {Collection<Snowflake, Message>} messages A collection of found messages
* @property {number} total The total number of messages that match the search criteria
*/
/**
* Search Messages in the channel.
* @param {MessageSearchOptions} options Performs a search within the channel.
* @returns {MessageSearchResult}
*/
async search(options = {}) {
let { author, content, mentions, has, maxId, minId, channelId, pinned } = Object.assign(
{
author: [],
content: '',
mentions: [],
has: [],
maxId: null,
minId: null,
channelId: [],
pinned: false,
},
options,
);
const stringQuery = [];
const result = new Collection();
let data;
if (author.length > 0) stringQuery.push(author.map(id => `author_id=${id}`).join('&'));
if (content && content.length) stringQuery.push(`content=${encodeURIComponent(content)}`);
if (mentions.length > 0) stringQuery.push(mentions.map(id => `mentions=${id}`).join('&'));
has = has.filter(v => ['link', 'embed', 'file', 'video', 'image', 'sound', 'sticker'].includes(v));
if (has.length > 0) stringQuery.push(has.map(v => `has=${v}`).join('&'));
if (maxId) stringQuery.push(`max_id=${maxId}`);
if (minId) stringQuery.push(`min_id=${minId}`);
if (this.channel.guildId && channelId.length > 0) {
stringQuery.push(channelId.map(id => `channel_id=${id}`).join('&'));
}
if (typeof pinned == 'boolean') stringQuery.push(`pinned=${pinned}`);
// Main
if (!stringQuery.length) {
return {
messages: result,
total: 0,
};
}
if (this.channel.guildId) {
data = await this.client.api.guilds[this.channel.guildId].messages[`search?${stringQuery.join('&')}`].get();
} else {
data = await this.client.api.channels[this.channel.id].messages[`search?${stringQuery.join('&')}`].get();
}
for await (const message of data.messages) result.set(message[0].id, new Message(this.client, message[0]));
return {
messages: result,
total: data.total_results,
};
}
}
module.exports = MessageManager;

View File

@ -1,16 +1,17 @@
'use strict';
const { Collection } = require('@discordjs/collection');
const Discord = require('discord.js-selfbot-v13');
const CachedManager = require('./CachedManager');
const { Error } = require('../errors');
const { lazy } = require('../util/Util');
const User = lazy(() => require('../structures/User'));
/**
* Manages API methods for users who reacted to a reaction and stores their cache.
* @extends {CachedManager}
*/
class ReactionUserManager extends CachedManager {
constructor(reaction, iterable) {
super(reaction.client, Discord.User, iterable);
super(reaction.client, User(), iterable);
/**
* The reaction that this manager belongs to

View File

@ -1,12 +1,13 @@
'use strict';
const { Message } = require('discord.js');
const Base = require('./Base');
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
const MessageAttachment = require('../structures/MessageAttachment');
const { ApplicationCommandOptionTypes, ApplicationCommandTypes, ChannelTypes } = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
const SnowflakeUtil = require('../util/SnowflakeUtil');
const { lazy } = require('../util/Util');
const Message = lazy(() => require('../structures/Message').Message);
/**
* Represents an application command.
* @extends {Base}
@ -506,7 +507,7 @@ class ApplicationCommand extends Base {
* Send Slash command to channel
* @param {Message} message Discord Message
* @param {Array<string>} options The options to Slash Command
* @returns {Promise<boolean>}
* @returns {Promise<Snowflake>} Nonce (Discord Timestamp) when command was sent
* @example
* const botID = '12345678987654321'
* const user = await client.users.fetch(botID);
@ -516,7 +517,7 @@ class ApplicationCommand extends Base {
*/
async sendSlashCommand(message, options = []) {
// Check Options
if (!(message instanceof Message)) {
if (!(message instanceof Message())) {
throw new TypeError('The message must be a Discord.Message');
}
if (!Array.isArray(options)) {
@ -630,6 +631,7 @@ class ApplicationCommand extends Base {
if (subCommandCheck && subCommand?.options && subCommand?.options[i]?.required) {
throw new Error('Value required missing');
}
let nonce = SnowflakeUtil.generate();
const data = {
type: 2, // Slash command, context menu
// Type: 4: Auto-complete
@ -646,7 +648,7 @@ class ApplicationCommand extends Base {
options: option_,
attachments: attachments,
},
nonce: SnowflakeUtil.generate(),
nonce,
};
await this.client.api.interactions
.post({
@ -654,19 +656,21 @@ class ApplicationCommand extends Base {
files: attachmentsBuffer,
})
.catch(async () => {
nonce = SnowflakeUtil.generate();
data.data.guild_id = message.guildId;
data.nonce = nonce;
await this.client.api.interactions.post({
body: data,
files: attachmentsBuffer,
});
});
return true;
return nonce;
}
/**
* Message Context Menu
* @param {Message} message Discord Message
* @param {boolean} sendFromMessage nothing .-. not used
* @returns {Promise<boolean>}
* @returns {Promise<Snowflake>} Nonce (Discord Timestamp) when command was sent
* @example
* const botID = '12345678987654321'
* const user = await client.users.fetch(botID);
@ -675,10 +679,11 @@ class ApplicationCommand extends Base {
* await command.sendContextMenu(messsage);
*/
async sendContextMenu(message, sendFromMessage = false) {
if (!sendFromMessage && !(message instanceof Message)) {
if (!sendFromMessage && !(message instanceof Message())) {
throw new TypeError('The message must be a Discord.Message');
}
if (this.type == 'CHAT_INPUT') return false;
const nonce = SnowflakeUtil.generate();
await this.client.api.interactions.post({
body: {
type: 2, // Slash command, context menu
@ -694,10 +699,10 @@ class ApplicationCommand extends Base {
type: ApplicationCommandTypes[this.type],
target_id: ApplicationCommandTypes[this.type] == 1 ? message.author.id : message.id,
},
nonce: SnowflakeUtil.generate(),
nonce,
},
});
return true;
return nonce;
}
}

View File

@ -1076,7 +1076,7 @@ class Message extends Base {
* Send context Menu v2
* @param {Snowflake} botId Bot id
* @param {string} commandName Command name in Context Menu
* @returns {Promise<void>}
* @returns {Promise<Snowflake>} Nonce (Discord Timestamp) when command was sent
*/
async contextMenu(botId, commandName) {
if (!botId) throw new Error('Bot ID is required');
@ -1112,7 +1112,8 @@ class Message extends Base {
.join(', ')}`,
);
}
return contextCMD.sendContextMenu(this, true);
const nonce = await contextCMD.sendContextMenu(this, true);
return nonce;
}
}

View File

@ -138,7 +138,7 @@ class Modal {
* @param {Snowflake} guildId GuildID of the guild to send the modal to
* @param {Snowflake} channelId ChannelID of the channel to send the modal to
* @param {...ModalReplyData} data Data to send with the modal
* @returns {Promise<boolean>}
* @returns {Promise<Snowflake>} Nonce (Discord Timestamp) when command was sent
* @example
* // With Event
* client.on('interactionModalCreate', modal => {
@ -199,19 +199,20 @@ class Modal {
// Get Object
const dataFinal = this.toJSON();
delete dataFinal.title;
const nonce = SnowflakeUtil.generate();
const postData = {
type: 5, // Modal
application_id: this.application.id,
guild_id: guildId,
channel_id: channelId,
data: dataFinal,
nonce: SnowflakeUtil.generate(),
nonce,
session_id: this.client.session_id,
};
await this.client.api.interactions.post({
data: postData,
});
return true;
return nonce;
}
}

View File

@ -1,7 +1,6 @@
'use strict';
/* eslint-disable import/order */
const { Message } = require('discord.js');
const MessageCollector = require('../MessageCollector');
const MessagePayload = require('../MessagePayload');
const SnowflakeUtil = require('../../util/SnowflakeUtil');
@ -9,6 +8,8 @@ const { Collection } = require('@discordjs/collection');
const { InteractionTypes } = require('../../util/Constants');
const { TypeError, Error } = require('../../errors');
const InteractionCollector = require('../InteractionCollector');
const { lazy } = require('../../util/Util');
const Message = lazy(() => require('../Message').Message);
/**
* Interface for classes that have text-channel-like features.
@ -394,7 +395,7 @@ class TextBasedChannel {
* @param {Snowflake} botId Bot Id (Supports application ID - not bot)
* @param {string} commandName Command name
* @param {...?string} args Command arguments
* @returns {Promise<pending>}
* @returns {Promise<Snowflake>} Nonce (Discord Timestamp) when command was sent
*/
async sendSlash(botId, commandName, ...args) {
if (!botId) throw new Error('Bot ID is required');
@ -432,8 +433,8 @@ class TextBasedChannel {
)}`,
);
}
return commandTarget.sendSlashCommand(
new Message(this.client, {
const nonce = await commandTarget.sendSlashCommand(
new (Message())(this.client, {
channel_id: this.id,
guild_id: this.guild?.id || null,
author: this.client.user,
@ -442,6 +443,7 @@ class TextBasedChannel {
}),
args && args.length ? args : [],
);
return nonce;
}
static applyToClass(structure, full = false, ignore = []) {

View File

@ -625,6 +625,19 @@ class Util extends null {
if (features.includes('THREE_DAY_THREAD_ARCHIVE')) return 4320;
return 1440;
}
/**
* Lazily evaluates a callback function (yea it's v14 :yay:)
* @param {Function} cb The callback to lazily evaluate
* @returns {Function}
* @example
* const User = lazy(() => require('./User'));
* const user = new (User())(client, data);
*/
static lazy(cb) {
let defaultValue;
return () => (defaultValue ??= cb());
}
}
module.exports = Util;

33
typings/index.d.ts vendored
View File

@ -279,8 +279,8 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
private static transformCommand(command: ApplicationCommandData): RESTPostAPIApplicationCommandsJSONBody;
private static isAPICommandData(command: object): command is RESTPostAPIApplicationCommandsJSONBody;
// Add
public static sendSlashCommand(message: Message, options?: string[]): Promise<boolean>;
public static sendContextMenu(message: Message): Promise<boolean>;
public static sendSlashCommand(message: Message, options?: string[]): Promise<Snowflake>;
public static sendContextMenu(message: Message): Promise<Snowflake>;
}
export type ApplicationResolvable = Application | Activity | Snowflake;
@ -702,7 +702,11 @@ export class ClientUser extends User {
public setDeaf(status: boolean): Promise<boolean>;
public setMute(status: boolean): Promise<boolean>;
public getInvite(options?: CreateInviteOptions): Promise<Invite>;
public getMentions(limit?: number, mentionRoles?: boolean, mentionEveryone?: boolean): Promise<Collection<Snowflake, Message>>;
public getMentions(
limit?: number,
mentionRoles?: boolean,
mentionEveryone?: boolean,
): Promise<Collection<Snowflake, Message>>;
/**
* Nitro Status
* `0`: None
@ -1673,7 +1677,7 @@ export class Message<Cached extends boolean = boolean> extends Base {
public clickButton(buttonID: string): Promise<void>;
public selectMenu(menuID: string, options: string[]): Promise<void>;
public selectMenu(options: string[]): Promise<void>;
public contextMenu(botID: Snowflake, commandName: string): Promise<void>;
public contextMenu(botID: Snowflake, commandName: string): Promise<Snowflake>;
}
export class MessageActionRow<
@ -2002,7 +2006,7 @@ export class Modal {
): this;
public setTitle(title: string): this;
public toJSON(): RawModalSubmitInteractionData;
public reply(guildId: Snowflake, channelId: Snowflake, ...args: ModalReplyData[]): Promise<boolean>;
public reply(guildId: Snowflake, channelId: Snowflake, ...args: ModalReplyData[]): Promise<Snowflake>;
}
export interface ModalReplyData {
@ -3558,6 +3562,23 @@ export class MessageManager extends CachedManager<Snowflake, Message, MessageRes
public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
public pin(message: MessageResolvable, reason?: string): Promise<void>;
public unpin(message: MessageResolvable, reason?: string): Promise<void>;
public search(options: MessageSearchOptions): Promise<MessageSearchResult>;
}
export interface MessageSearchOptions {
author: Snowflake[];
content: string;
mentions: Snowflake[];
has: ('link' | 'embed' | 'file' | 'video' | 'image' | 'sound' | 'sticker')[];
maxId: Snowflake;
minId: Snowflake;
channelId: Snowflake[];
pinned: boolean;
}
export interface MessageSearchResult {
messages: Collection<Snowflake, Message>;
total: number;
}
export class PermissionOverwriteManager extends CachedManager<
@ -3720,7 +3741,7 @@ export interface TextBasedChannelFields extends PartialTextBasedChannelFields {
setNSFW(nsfw?: boolean, reason?: string): Promise<this>;
fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
sendTyping(): Promise<void>;
sendSlash(botId: Snowflake, commandName: string, ...args: any): Promise<undefined>;
sendSlash(botId: Snowflake, commandName: string, ...args: any): Promise<Snowflake>;
}
export function PartialWebhookMixin<T>(Base?: Constructable<T>): Constructable<T & PartialWebhookFields>;