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:
parent
fb6ab3f8e8
commit
fad6d708b4
File diff suppressed because one or more lines are too long
1429
package-lock.json
generated
1429
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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]",
|
||||
"main": "./src/index.js",
|
||||
"types": "./typings/index.d.ts",
|
||||
@ -56,13 +56,12 @@
|
||||
"@discordjs/collection": "^0.7.0",
|
||||
"@discordjs/voice": "^0.10.0",
|
||||
"@sapphire/async-queue": "^1.3.1",
|
||||
"@types/node-fetch": "^2.6.1",
|
||||
"@types/node-fetch": "^2.6.2",
|
||||
"@types/ws": "^8.5.3",
|
||||
"axios": "^0.27.2",
|
||||
"bignumber.js": "^9.0.2",
|
||||
"chalk": "^4.1.2",
|
||||
"discord-api-types": "^0.36.0",
|
||||
"discord-bettermarkdown": "^1.2.0",
|
||||
"discord-api-types": "^0.36.2",
|
||||
"form-data": "^4.0.0",
|
||||
"json-bigint": "^1.0.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
@ -88,7 +87,7 @@
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"husky": "^7.0.4",
|
||||
"is-ci": "^3.0.1",
|
||||
"jest": "^28.1.0",
|
||||
"jest": "^28.1.3",
|
||||
"lint-staged": "^12.1.4",
|
||||
"prettier": "^2.5.1",
|
||||
"tsd": "^0.22.0",
|
||||
|
15
src/client/websocket/handlers/CALL_CREATE.js
Normal file
15
src/client/websocket/handlers/CALL_CREATE.js
Normal 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);
|
||||
};
|
10
src/client/websocket/handlers/CALL_DELETE.js
Normal file
10
src/client/websocket/handlers/CALL_DELETE.js
Normal 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);
|
||||
};
|
12
src/client/websocket/handlers/CALL_UPDATE.js
Normal file
12
src/client/websocket/handlers/CALL_UPDATE.js
Normal 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);
|
||||
};
|
@ -115,7 +115,13 @@ module.exports = (client, { d: data }, shard) => {
|
||||
client.user._patchNote(data.notes);
|
||||
|
||||
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
|
||||
|
||||
|
@ -9,6 +9,9 @@ const handlers = Object.fromEntries([
|
||||
['APPLICATION_COMMAND_CREATE', require('./APPLICATION_COMMAND_CREATE')],
|
||||
['APPLICATION_COMMAND_DELETE', require('./APPLICATION_COMMAND_DELETE')],
|
||||
['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_DELETE', require('./GUILD_DELETE')],
|
||||
['GUILD_UPDATE', require('./GUILD_UPDATE')],
|
||||
|
@ -67,6 +67,7 @@ const Messages = {
|
||||
|
||||
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!',
|
||||
CLIENT_NO_CALL: 'No call exists!',
|
||||
|
||||
VOICE_NOT_STAGE_CHANNEL: 'You are only allowed to do this in stage channels.',
|
||||
|
||||
|
@ -221,11 +221,11 @@ class MessageManager extends CachedManager {
|
||||
}
|
||||
|
||||
// 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
|
||||
// Remove channelId from url (around not working)
|
||||
// https://canary.discord.com/api/v9/guilds/809133733591384155/messages/search?channel_id=840225732902518825&max_id=957254525360697375&min_id=957254525360697373
|
||||
const data = (
|
||||
await this.client.api.guilds[this.channel.guild.id].messages.search.get({
|
||||
query: {
|
||||
channel_id: this.channel.id,
|
||||
max_id: new BigNumber.BigNumber(messageId).plus(1).toString(),
|
||||
min_id: new BigNumber.BigNumber(messageId).minus(1).toString(),
|
||||
},
|
||||
|
@ -177,6 +177,7 @@ class BaseGuildTextChannel extends GuildChannel {
|
||||
createWebhook() {}
|
||||
setRateLimitPerUser() {}
|
||||
setNSFW() {}
|
||||
sendSlash() {}
|
||||
}
|
||||
|
||||
TextBasedChannel.applyToClass(BaseGuildTextChannel, true);
|
||||
|
@ -95,6 +95,7 @@ class DMChannel extends Channel {
|
||||
awaitMessages() {}
|
||||
createMessageComponentCollector() {}
|
||||
awaitMessageComponent() {}
|
||||
sendSlash() {}
|
||||
// Doesn't work on DM channels; bulkDelete() {}
|
||||
// Doesn't work on DM channels; setRateLimitPerUser() {}
|
||||
// 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
|
||||
/**
|
||||
* 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>}
|
||||
*/
|
||||
call(options = {}) {
|
||||
|
@ -4,7 +4,6 @@ const { Collection } = require('@discordjs/collection');
|
||||
const { joinVoiceChannel, entersState, VoiceConnectionStatus } = require('@discordjs/voice');
|
||||
const { Channel } = require('./Channel');
|
||||
const Invite = require('./Invite');
|
||||
const User = require('./User');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const { Error } = require('../errors');
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a user to this Group DM Channel.
|
||||
* @param {UserResolvable} user User to add to the group
|
||||
* @returns {Promise<PartialGroupDMChannel>}
|
||||
*/
|
||||
async addMember(user) {
|
||||
if (this.ownerId !== this.client.user.id) {
|
||||
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
|
||||
}
|
||||
if (!(user instanceof User)) {
|
||||
return Promise.reject(new TypeError('User is not an instance of Discord.User'));
|
||||
user = this.client.users.resolveId(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();
|
||||
this.recipients.set(user.id, user);
|
||||
await this.client.api.channels[this.id].recipients[user].put();
|
||||
this.recipients.set(user, this.client.users.cache.get(user));
|
||||
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) {
|
||||
if (this.ownerId !== this.client.user.id) {
|
||||
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
|
||||
}
|
||||
if (!(user instanceof User)) {
|
||||
return Promise.reject(new TypeError('User is not an instance of Discord.User'));
|
||||
user = this.client.users.resolveId(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'));
|
||||
await this.client.api.channels[this.id].recipients[user.id].delete();
|
||||
this.recipients.delete(user.id);
|
||||
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].delete();
|
||||
this.recipients.delete(user);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames this Group DM Channel.
|
||||
* @param {?string} name Name of the channel
|
||||
* @returns {Promise<PartialGroupDMChannel>}
|
||||
*/
|
||||
setName(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) {
|
||||
return this.edit({ icon });
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the invite for this Group DM Channel.
|
||||
* @returns {Promise<Invite>}
|
||||
*/
|
||||
async getInvite() {
|
||||
const inviteCode = await this.client.api.channels(this.id).invites.post({
|
||||
data: {
|
||||
@ -174,6 +199,11 @@ class PartialGroupDMChannel extends Channel {
|
||||
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) {
|
||||
if (this.ownerId !== this.client.user.id) {
|
||||
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
|
||||
@ -184,6 +214,11 @@ class PartialGroupDMChannel extends Channel {
|
||||
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) {
|
||||
if (this.ownerId !== this.client.user.id) {
|
||||
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
|
||||
@ -203,11 +238,16 @@ class PartialGroupDMChannel extends Channel {
|
||||
send() {}
|
||||
sendTyping() {}
|
||||
|
||||
/**
|
||||
* @typedef {Object} CallOptions
|
||||
* @property {boolean} [selfDeaf] Whether to deafen yourself
|
||||
* @property {boolean} [selfMute] Whether to mute yourself
|
||||
*/
|
||||
// Testing feature: Call
|
||||
// URL: https://discord.com/api/v9/channels/DMchannelId/call/ring
|
||||
/**
|
||||
* 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>}
|
||||
*/
|
||||
call(options = {}) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
const { default: Collection } = require('@discordjs/collection');
|
||||
const Base = require('./Base');
|
||||
const ClientApplication = require('./ClientApplication');
|
||||
const VoiceState = require('./VoiceState');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const { Error } = require('../errors');
|
||||
const { RelationshipTypes } = require('../util/Constants');
|
||||
@ -189,6 +190,15 @@ class User extends Base {
|
||||
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) {
|
||||
if (!data) return;
|
||||
|
||||
@ -351,6 +361,26 @@ class User extends Base {
|
||||
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
|
||||
* @type {?string}
|
||||
|
@ -396,10 +396,11 @@ class TextBasedChannel {
|
||||
* Send Slash to this channel
|
||||
* @param {Snowflake} botId Bot Id (Supports application ID - not bot)
|
||||
* @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
|
||||
*/
|
||||
async sendSlash(botId, commandName, ...args) {
|
||||
args = args.flat(2);
|
||||
if (!botId) throw new Error('Bot ID is required');
|
||||
// ? maybe ...
|
||||
const user = await this.client.users.fetch(botId).catch(() => {});
|
||||
|
@ -262,6 +262,9 @@ exports.Opcodes = {
|
||||
* * APPLICATION_COMMAND_CREATE: applicationCommandCreate (deprecated)
|
||||
* * APPLICATION_COMMAND_DELETE: applicationCommandDelete (deprecated)
|
||||
* * APPLICATION_COMMAND_UPDATE: applicationCommandUpdate (deprecated)
|
||||
* * CALL_CREATE: callCreate
|
||||
* * CALL_DELETE: callDelete
|
||||
* * CALL_UPDATE: callUpdate
|
||||
* * GUILD_CREATE: guildCreate
|
||||
* * GUILD_DELETE: guildDelete
|
||||
* * GUILD_UPDATE: guildUpdate
|
||||
@ -341,6 +344,9 @@ exports.Events = {
|
||||
APPLICATION_COMMAND_CREATE: 'applicationCommandCreate',
|
||||
APPLICATION_COMMAND_DELETE: 'applicationCommandDelete',
|
||||
APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate',
|
||||
CALL_CREATE: 'callCreate',
|
||||
CALL_DELETE: 'callDelete',
|
||||
CALL_UPDATE: 'callUpdate',
|
||||
GUILD_CREATE: 'guildCreate',
|
||||
GUILD_DELETE: 'guildDelete',
|
||||
GUILD_UPDATE: 'guildUpdate',
|
||||
|
6
typings/index.d.ts
vendored
6
typings/index.d.ts
vendored
@ -4222,6 +4222,9 @@ export interface ClientEvents extends BaseClientEvents {
|
||||
emojiDelete: [emoji: GuildEmoji];
|
||||
emojiUpdate: [oldEmoji: GuildEmoji, newEmoji: GuildEmoji];
|
||||
error: [error: Error];
|
||||
callCreate: [channelId: Snowflake, region: string, ringing?: Snowflake[]];
|
||||
callDelete: [channelId: Snowflake];
|
||||
callUpdate: [channelId: Snowflake, region: string, ringing?: Snowflake[]];
|
||||
guildBanAdd: [ban: GuildBan];
|
||||
guildBanRemove: [ban: GuildBan];
|
||||
guildCreate: [guild: Guild];
|
||||
@ -4319,6 +4322,9 @@ export interface ConstantsEvents {
|
||||
APPLICATION_COMMAND_DELETE: 'applicationCommandDelete';
|
||||
/** @deprecated See [this issue](https://github.com/discord/discord-api-docs/issues/3690) for more information. */
|
||||
APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate';
|
||||
CALL_CREATE: 'callCreate';
|
||||
CALL_DELETE: 'callDelete';
|
||||
CALL_UPDATE: 'callUpdate';
|
||||
GUILD_CREATE: 'guildCreate';
|
||||
GUILD_DELETE: 'guildDelete';
|
||||
GUILD_UPDATE: 'guildUpdate';
|
||||
|
Loading…
Reference in New Issue
Block a user