chore(release): v2.3.75

- fix: VoiceStateUpdate event not working (DM channels + Group DM channels)
- docs: add sendSlash method
- feat: Add new Event: callCreate, callUpdate, callDelete
- fix(GroupDM): method require Class
This commit is contained in:
March 7th 2022-07-15 17:26:25 +07:00
parent fb6ab3f8e8
commit fad6d708b4
17 changed files with 826 additions and 780 deletions

File diff suppressed because one or more lines are too long

1429
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "discord.js-selfbot-v13", "name": "discord.js-selfbot-v13",
"version": "2.3.74", "version": "2.3.75",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]", "description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js", "main": "./src/index.js",
"types": "./typings/index.d.ts", "types": "./typings/index.d.ts",
@ -56,13 +56,12 @@
"@discordjs/collection": "^0.7.0", "@discordjs/collection": "^0.7.0",
"@discordjs/voice": "^0.10.0", "@discordjs/voice": "^0.10.0",
"@sapphire/async-queue": "^1.3.1", "@sapphire/async-queue": "^1.3.1",
"@types/node-fetch": "^2.6.1", "@types/node-fetch": "^2.6.2",
"@types/ws": "^8.5.3", "@types/ws": "^8.5.3",
"axios": "^0.27.2", "axios": "^0.27.2",
"bignumber.js": "^9.0.2", "bignumber.js": "^9.0.2",
"chalk": "^4.1.2", "chalk": "^4.1.2",
"discord-api-types": "^0.36.0", "discord-api-types": "^0.36.2",
"discord-bettermarkdown": "^1.2.0",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"json-bigint": "^1.0.0", "json-bigint": "^1.0.0",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
@ -88,7 +87,7 @@
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4", "husky": "^7.0.4",
"is-ci": "^3.0.1", "is-ci": "^3.0.1",
"jest": "^28.1.0", "jest": "^28.1.3",
"lint-staged": "^12.1.4", "lint-staged": "^12.1.4",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"tsd": "^0.22.0", "tsd": "^0.22.0",

View File

@ -0,0 +1,15 @@
'use strict';
const { Events } = require('../../../util/Constants');
module.exports = (client, packet) => {
for (const voice of packet.d.voice_states) {
client.actions.VoiceStateUpdate.handle(voice);
}
/**
* Emitted whenever received a call
* @event Client#callCreate
* @param {Snowflake} channelId DM / Group DM channel ID
* @param {string} region Voice server region
* @param {?Snowflake[]} ringing List of user ID who is ringing
*/
client.emit(Events.CALL_CREATE, packet.d.channel_id, packet.d.region, packet.d.ringing);
};

View File

@ -0,0 +1,10 @@
'use strict';
const { Events } = require('../../../util/Constants');
module.exports = (client, packet) => {
/**
* Emitted whenever delete a call
* @event Client#callDelete
* @param {Snowflake} channelId DM / Group DM channel ID
*/
client.emit(Events.CALL_DELETE, packet.d.channel_id);
};

View File

@ -0,0 +1,12 @@
'use strict';
const { Events } = require('../../../util/Constants');
module.exports = (client, packet) => {
/**
* Emitted whenever update a call
* @event Client#callUpdate
* @param {Snowflake} channelId DM / Group DM channel ID
* @param {string} region Voice server region
* @param {?Snowflake[]} ringing List of user ID who is ringing
*/
client.emit(Events.CALL_UPDATE, packet.d.channel_id, packet.d.region, packet.d.ringing);
};

View File

@ -115,7 +115,13 @@ module.exports = (client, { d: data }, shard) => {
client.user._patchNote(data.notes); client.user._patchNote(data.notes);
for (const private_channel of data.private_channels) { for (const private_channel of data.private_channels) {
client.channels._add(private_channel); const PrivateChannel = client.channels._add(private_channel);
client.ws.broadcast({
op: Opcodes.DM_UPDATE,
d: {
channel_id: PrivateChannel.id,
},
});
} }
// Remove event because memory leak // Remove event because memory leak

View File

@ -9,6 +9,9 @@ const handlers = Object.fromEntries([
['APPLICATION_COMMAND_CREATE', require('./APPLICATION_COMMAND_CREATE')], ['APPLICATION_COMMAND_CREATE', require('./APPLICATION_COMMAND_CREATE')],
['APPLICATION_COMMAND_DELETE', require('./APPLICATION_COMMAND_DELETE')], ['APPLICATION_COMMAND_DELETE', require('./APPLICATION_COMMAND_DELETE')],
['APPLICATION_COMMAND_UPDATE', require('./APPLICATION_COMMAND_UPDATE')], ['APPLICATION_COMMAND_UPDATE', require('./APPLICATION_COMMAND_UPDATE')],
['CALL_CREATE', require('./CALL_CREATE')],
['CALL_UPDATE', require('./CALL_UPDATE')],
['CALL_DELETE', require('./CALL_DELETE')],
['GUILD_CREATE', require('./GUILD_CREATE')], ['GUILD_CREATE', require('./GUILD_CREATE')],
['GUILD_DELETE', require('./GUILD_DELETE')], ['GUILD_DELETE', require('./GUILD_DELETE')],
['GUILD_UPDATE', require('./GUILD_UPDATE')], ['GUILD_UPDATE', require('./GUILD_UPDATE')],

View File

@ -67,6 +67,7 @@ const Messages = {
USER_BANNER_NOT_FETCHED: "You must fetch this user's banner before trying to generate its URL!", USER_BANNER_NOT_FETCHED: "You must fetch this user's banner before trying to generate its URL!",
USER_NO_DM_CHANNEL: 'No DM Channel exists!', USER_NO_DM_CHANNEL: 'No DM Channel exists!',
CLIENT_NO_CALL: 'No call exists!',
VOICE_NOT_STAGE_CHANNEL: 'You are only allowed to do this in stage channels.', VOICE_NOT_STAGE_CHANNEL: 'You are only allowed to do this in stage channels.',

View File

@ -221,11 +221,11 @@ class MessageManager extends CachedManager {
} }
// Const data = await this.client.api.channels[this.channel.id].messages[messageId].get(); // Discord Block // Const data = await this.client.api.channels[this.channel.id].messages[messageId].get(); // Discord Block
// https://canary.discord.com/api/v9/guilds/809133733591384155/messages/search?max_id=957254525360697375&min_id=957254525360697373 // https://canary.discord.com/api/v9/guilds/809133733591384155/messages/search?channel_id=840225732902518825&max_id=957254525360697375&min_id=957254525360697373
// Remove channelId from url (around not working)
const data = ( const data = (
await this.client.api.guilds[this.channel.guild.id].messages.search.get({ await this.client.api.guilds[this.channel.guild.id].messages.search.get({
query: { query: {
channel_id: this.channel.id,
max_id: new BigNumber.BigNumber(messageId).plus(1).toString(), max_id: new BigNumber.BigNumber(messageId).plus(1).toString(),
min_id: new BigNumber.BigNumber(messageId).minus(1).toString(), min_id: new BigNumber.BigNumber(messageId).minus(1).toString(),
}, },

View File

@ -177,6 +177,7 @@ class BaseGuildTextChannel extends GuildChannel {
createWebhook() {} createWebhook() {}
setRateLimitPerUser() {} setRateLimitPerUser() {}
setNSFW() {} setNSFW() {}
sendSlash() {}
} }
TextBasedChannel.applyToClass(BaseGuildTextChannel, true); TextBasedChannel.applyToClass(BaseGuildTextChannel, true);

View File

@ -95,6 +95,7 @@ class DMChannel extends Channel {
awaitMessages() {} awaitMessages() {}
createMessageComponentCollector() {} createMessageComponentCollector() {}
awaitMessageComponent() {} awaitMessageComponent() {}
sendSlash() {}
// Doesn't work on DM channels; bulkDelete() {} // Doesn't work on DM channels; bulkDelete() {}
// Doesn't work on DM channels; setRateLimitPerUser() {} // Doesn't work on DM channels; setRateLimitPerUser() {}
// Doesn't work on DM channels; setNSFW() {} // Doesn't work on DM channels; setNSFW() {}
@ -102,7 +103,7 @@ class DMChannel extends Channel {
// URL: https://discord.com/api/v9/channels/DMchannelId/call/ring // URL: https://discord.com/api/v9/channels/DMchannelId/call/ring
/** /**
* Call this DMChannel. Return discordjs/voice VoiceConnection * Call this DMChannel. Return discordjs/voice VoiceConnection
* @param {Object} options Options for the call (selfDeaf, selfMute: Boolean) * @param {CallOptions} options Options for the call
* @returns {Promise<VoiceConnection>} * @returns {Promise<VoiceConnection>}
*/ */
call(options = {}) { call(options = {}) {

View File

@ -4,7 +4,6 @@ const { Collection } = require('@discordjs/collection');
const { joinVoiceChannel, entersState, VoiceConnectionStatus } = require('@discordjs/voice'); const { joinVoiceChannel, entersState, VoiceConnectionStatus } = require('@discordjs/voice');
const { Channel } = require('./Channel'); const { Channel } = require('./Channel');
const Invite = require('./Invite'); const Invite = require('./Invite');
const User = require('./User');
const TextBasedChannel = require('./interfaces/TextBasedChannel'); const TextBasedChannel = require('./interfaces/TextBasedChannel');
const { Error } = require('../errors'); const { Error } = require('../errors');
const MessageManager = require('../managers/MessageManager'); const MessageManager = require('../managers/MessageManager');
@ -128,41 +127,67 @@ class PartialGroupDMChannel extends Channel {
return this.icon && this.client.rest.cdn.GDMIcon(this.id, this.icon, format, size); return this.icon && this.client.rest.cdn.GDMIcon(this.id, this.icon, format, size);
} }
/**
* Adds a user to this Group DM Channel.
* @param {UserResolvable} user User to add to the group
* @returns {Promise<PartialGroupDMChannel>}
*/
async addMember(user) { async addMember(user) {
if (this.ownerId !== this.client.user.id) { if (this.ownerId !== this.client.user.id) {
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL')); return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
} }
if (!(user instanceof User)) { user = this.client.users.resolveId(user);
return Promise.reject(new TypeError('User is not an instance of Discord.User')); if (!user) {
return Promise.reject(new TypeError('User is not a User or User ID'));
} }
if (this.recipients.get(user.id)) return Promise.reject(new Error('USER_ALREADY_IN_GROUP_DM_CHANNEL')); if (this.recipients.get(user)) return Promise.reject(new Error('USER_ALREADY_IN_GROUP_DM_CHANNEL'));
// //
await this.client.api.channels[this.id].recipients[user.id].put(); await this.client.api.channels[this.id].recipients[user].put();
this.recipients.set(user.id, user); this.recipients.set(user, this.client.users.cache.get(user));
return this; return this;
} }
/**
* Removes a user from this Group DM Channel.
* @param {UserResolvable} user User to remove from the group
* @returns {Promise<PartialGroupDMChannel>}
*/
async removeMember(user) { async removeMember(user) {
if (this.ownerId !== this.client.user.id) { if (this.ownerId !== this.client.user.id) {
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL')); return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
} }
if (!(user instanceof User)) { user = this.client.users.resolveId(user);
return Promise.reject(new TypeError('User is not an instance of Discord.User')); if (!user) {
return Promise.reject(new TypeError('User is not a User or User ID'));
} }
if (!this.recipients.get(user.id)) return Promise.reject(new Error('USER_NOT_IN_GROUP_DM_CHANNEL')); if (!this.recipients.get(user)) return Promise.reject(new Error('USER_NOT_IN_GROUP_DM_CHANNEL'));
await this.client.api.channels[this.id].recipients[user.id].delete(); await this.client.api.channels[this.id].recipients[user].delete();
this.recipients.delete(user.id); this.recipients.delete(user);
return this; return this;
} }
/**
* Renames this Group DM Channel.
* @param {?string} name Name of the channel
* @returns {Promise<PartialGroupDMChannel>}
*/
setName(name) { setName(name) {
return this.edit({ name }); return this.edit({ name });
} }
/**
* Sets the icon of this Group DM Channel.
* @param {?(Base64Resolvable|BufferResolvable)} icon Icon of the channel
* @returns {Promise<PartialGroupDMChannel>}
*/
setIcon(icon) { setIcon(icon) {
return this.edit({ icon }); return this.edit({ icon });
} }
/**
* Gets the invite for this Group DM Channel.
* @returns {Promise<Invite>}
*/
async getInvite() { async getInvite() {
const inviteCode = await this.client.api.channels(this.id).invites.post({ const inviteCode = await this.client.api.channels(this.id).invites.post({
data: { data: {
@ -174,6 +199,11 @@ class PartialGroupDMChannel extends Channel {
return invite; return invite;
} }
/**
* Get all the invites for this Group DM Channel.
* @param {boolean} force Using API to fetch invites or cache
* @returns {Promise<Collection<string, Invite>>}
*/
async fetchInvite(force = false) { async fetchInvite(force = false) {
if (this.ownerId !== this.client.user.id) { if (this.ownerId !== this.client.user.id) {
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL')); return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
@ -184,6 +214,11 @@ class PartialGroupDMChannel extends Channel {
return this.invites; return this.invites;
} }
/**
* Delete invites from this Group DM Channel.
* @param {Invite} invite Invite to add to the channel
* @returns {Promise<PartialGroupDMChannel>}
*/
async removeInvite(invite) { async removeInvite(invite) {
if (this.ownerId !== this.client.user.id) { if (this.ownerId !== this.client.user.id) {
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL')); return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
@ -203,11 +238,16 @@ class PartialGroupDMChannel extends Channel {
send() {} send() {}
sendTyping() {} sendTyping() {}
/**
* @typedef {Object} CallOptions
* @property {boolean} [selfDeaf] Whether to deafen yourself
* @property {boolean} [selfMute] Whether to mute yourself
*/
// Testing feature: Call // Testing feature: Call
// URL: https://discord.com/api/v9/channels/DMchannelId/call/ring // URL: https://discord.com/api/v9/channels/DMchannelId/call/ring
/** /**
* Call this Group DMChannel. Return discordjs/voice VoiceConnection * Call this Group DMChannel. Return discordjs/voice VoiceConnection
* @param {Object} options Options for the call (selfDeaf, selfMute: Boolean) * @param {CallOptions} options Options for the call
* @returns {Promise<VoiceConnection>} * @returns {Promise<VoiceConnection>}
*/ */
call(options = {}) { call(options = {}) {

View File

@ -3,6 +3,7 @@
const { default: Collection } = require('@discordjs/collection'); const { default: Collection } = require('@discordjs/collection');
const Base = require('./Base'); const Base = require('./Base');
const ClientApplication = require('./ClientApplication'); const ClientApplication = require('./ClientApplication');
const VoiceState = require('./VoiceState');
const TextBasedChannel = require('./interfaces/TextBasedChannel'); const TextBasedChannel = require('./interfaces/TextBasedChannel');
const { Error } = require('../errors'); const { Error } = require('../errors');
const { RelationshipTypes } = require('../util/Constants'); const { RelationshipTypes } = require('../util/Constants');
@ -189,6 +190,15 @@ class User extends Base {
return this.client.user.notes.get(this.id); return this.client.user.notes.get(this.id);
} }
/**
* The voice state of this member
* @type {VoiceState}
* @readonly
*/
get voice() {
return this.client.voiceStates.cache.get(this.id) ?? new VoiceState({ client: this.client }, { user_id: this.id });
}
_ProfilePatch(data) { _ProfilePatch(data) {
if (!data) return; if (!data) return;
@ -351,6 +361,26 @@ class User extends Base {
return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic); return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic);
} }
ring() {
if (!this.dmChannel?.id) return Promise.reject(new Error('USER_NO_DM_CHANNEL'));
if (!this.client.user.voice?.channelId || !this.client.callVoice) {
return Promise.reject(new Error('CLIENT_NO_CALL'));
}
return new Promise((resolve, reject) => {
this.client.api
.channels(this.dmChannel.id)
.call.ring.post({
data: {
recipients: [this.id],
},
})
.then(() => resolve(true))
.catch(e => {
reject(e);
});
});
}
/** /**
* The Discord "tag" (e.g. `hydrabolt#0001`) for this user * The Discord "tag" (e.g. `hydrabolt#0001`) for this user
* @type {?string} * @type {?string}

View File

@ -396,10 +396,11 @@ class TextBasedChannel {
* Send Slash to this channel * Send Slash to this channel
* @param {Snowflake} botId Bot Id (Supports application ID - not bot) * @param {Snowflake} botId Bot Id (Supports application ID - not bot)
* @param {string} commandName Command name * @param {string} commandName Command name
* @param {...?string} args Command arguments * @param {...?string|string[]} args Command arguments
* @returns {Promise<Snowflake>} Nonce (Discord Timestamp) when command was sent * @returns {Promise<Snowflake>} Nonce (Discord Timestamp) when command was sent
*/ */
async sendSlash(botId, commandName, ...args) { async sendSlash(botId, commandName, ...args) {
args = args.flat(2);
if (!botId) throw new Error('Bot ID is required'); if (!botId) throw new Error('Bot ID is required');
// ? maybe ... // ? maybe ...
const user = await this.client.users.fetch(botId).catch(() => {}); const user = await this.client.users.fetch(botId).catch(() => {});

View File

@ -262,6 +262,9 @@ exports.Opcodes = {
* * APPLICATION_COMMAND_CREATE: applicationCommandCreate (deprecated) * * APPLICATION_COMMAND_CREATE: applicationCommandCreate (deprecated)
* * APPLICATION_COMMAND_DELETE: applicationCommandDelete (deprecated) * * APPLICATION_COMMAND_DELETE: applicationCommandDelete (deprecated)
* * APPLICATION_COMMAND_UPDATE: applicationCommandUpdate (deprecated) * * APPLICATION_COMMAND_UPDATE: applicationCommandUpdate (deprecated)
* * CALL_CREATE: callCreate
* * CALL_DELETE: callDelete
* * CALL_UPDATE: callUpdate
* * GUILD_CREATE: guildCreate * * GUILD_CREATE: guildCreate
* * GUILD_DELETE: guildDelete * * GUILD_DELETE: guildDelete
* * GUILD_UPDATE: guildUpdate * * GUILD_UPDATE: guildUpdate
@ -341,6 +344,9 @@ exports.Events = {
APPLICATION_COMMAND_CREATE: 'applicationCommandCreate', APPLICATION_COMMAND_CREATE: 'applicationCommandCreate',
APPLICATION_COMMAND_DELETE: 'applicationCommandDelete', APPLICATION_COMMAND_DELETE: 'applicationCommandDelete',
APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate', APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate',
CALL_CREATE: 'callCreate',
CALL_DELETE: 'callDelete',
CALL_UPDATE: 'callUpdate',
GUILD_CREATE: 'guildCreate', GUILD_CREATE: 'guildCreate',
GUILD_DELETE: 'guildDelete', GUILD_DELETE: 'guildDelete',
GUILD_UPDATE: 'guildUpdate', GUILD_UPDATE: 'guildUpdate',

6
typings/index.d.ts vendored
View File

@ -4222,6 +4222,9 @@ export interface ClientEvents extends BaseClientEvents {
emojiDelete: [emoji: GuildEmoji]; emojiDelete: [emoji: GuildEmoji];
emojiUpdate: [oldEmoji: GuildEmoji, newEmoji: GuildEmoji]; emojiUpdate: [oldEmoji: GuildEmoji, newEmoji: GuildEmoji];
error: [error: Error]; error: [error: Error];
callCreate: [channelId: Snowflake, region: string, ringing?: Snowflake[]];
callDelete: [channelId: Snowflake];
callUpdate: [channelId: Snowflake, region: string, ringing?: Snowflake[]];
guildBanAdd: [ban: GuildBan]; guildBanAdd: [ban: GuildBan];
guildBanRemove: [ban: GuildBan]; guildBanRemove: [ban: GuildBan];
guildCreate: [guild: Guild]; guildCreate: [guild: Guild];
@ -4319,6 +4322,9 @@ export interface ConstantsEvents {
APPLICATION_COMMAND_DELETE: 'applicationCommandDelete'; APPLICATION_COMMAND_DELETE: 'applicationCommandDelete';
/** @deprecated See [this issue](https://github.com/discord/discord-api-docs/issues/3690) for more information. */ /** @deprecated See [this issue](https://github.com/discord/discord-api-docs/issues/3690) for more information. */
APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate'; APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate';
CALL_CREATE: 'callCreate';
CALL_DELETE: 'callDelete';
CALL_UPDATE: 'callUpdate';
GUILD_CREATE: 'guildCreate'; GUILD_CREATE: 'guildCreate';
GUILD_DELETE: 'guildDelete'; GUILD_DELETE: 'guildDelete';
GUILD_UPDATE: 'guildUpdate'; GUILD_UPDATE: 'guildUpdate';