chore: deps + dev deps
+ Update @discordjs/builders + Update @discordjs/collection + Update @sapphire/shapeshift + Update discord-api-types + Update eslint + Update tsd - Remove @discordjs/voice + @discordjs/voice patch v0.13 + Fix `patchVoice` options
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
let ClientUser;
|
||||
const { VoiceConnection } = require('@discordjs/voice');
|
||||
const axios = require('axios');
|
||||
const chalk = require('chalk');
|
||||
const Discord = require('../../../index');
|
||||
const { Events, Opcodes } = require('../../../util/Constants');
|
||||
const { VoiceConnection: VoiceConnection_patch } = require('../../../util/Voice');
|
||||
let running = false;
|
||||
/**
|
||||
* Emitted whenever clientOptions.checkUpdate = false
|
||||
@@ -65,15 +63,38 @@ module.exports = async (client, { d: data }, shard) => {
|
||||
checkUpdate(client);
|
||||
|
||||
if (client.options.patchVoice && !running) {
|
||||
/* eslint-disable */
|
||||
VoiceConnection.prototype.configureNetworking = VoiceConnection_patch.prototype.configureNetworking;
|
||||
client.emit(
|
||||
Events.DEBUG,
|
||||
`${chalk.greenBright('[OK]')} Patched ${chalk.cyanBright(
|
||||
'VoiceConnection.prototype.configureNetworking',
|
||||
)} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.11.0')}]`,
|
||||
);
|
||||
/* eslint-enable */
|
||||
try {
|
||||
const { VoiceConnection } = require('@discordjs/voice');
|
||||
const { VoiceConnection: VoiceConnection_patch } = require('../../../util/Voice');
|
||||
/* eslint-disable */
|
||||
VoiceConnection.prototype.configureNetworking = VoiceConnection_patch.prototype.configureNetworking;
|
||||
client.emit(
|
||||
Events.DEBUG,
|
||||
`${chalk.greenBright('[OK]')} Patched ${chalk.cyanBright(
|
||||
'VoiceConnection.prototype.configureNetworking',
|
||||
)} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.13.0')}]`,
|
||||
);
|
||||
/* eslint-enable */
|
||||
} catch (e) {
|
||||
client.emit(
|
||||
Events.DEBUG,
|
||||
`${chalk.redBright('[Fail]')} Patched ${chalk.cyanBright(
|
||||
'VoiceConnection.prototype.configureNetworking',
|
||||
)} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.13.0')}]\n${e.stack}`,
|
||||
);
|
||||
client.emit(
|
||||
Events.ERROR,
|
||||
`${chalk.redBright('[Fail]')} Patched ${chalk.cyanBright(
|
||||
'VoiceConnection.prototype.configureNetworking',
|
||||
)} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.13.0')}]`,
|
||||
);
|
||||
client.emit(
|
||||
Events.ERROR,
|
||||
`${chalk.redBright('[Error]')} Please install ${chalk.bgMagentaBright(
|
||||
'@discordjs/voice',
|
||||
)} version ${chalk.redBright('v0.13.0')}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
client.session_id = data.session_id;
|
||||
|
@@ -116,31 +116,40 @@ class DMChannel extends Channel {
|
||||
*/
|
||||
call(options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.client.api
|
||||
.channels(this.id)
|
||||
.call.ring.post({
|
||||
data: {
|
||||
recipients: null,
|
||||
},
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Emit ring error:', e.message);
|
||||
});
|
||||
const connection = joinVoiceChannel({
|
||||
channelId: this.id,
|
||||
guildId: null,
|
||||
adapterCreator: this.voiceAdapterCreator,
|
||||
selfDeaf: options.selfDeaf ?? false,
|
||||
selfMute: options.selfMute ?? false,
|
||||
});
|
||||
entersState(connection, VoiceConnectionStatus.Ready, 30000)
|
||||
.then(connection => {
|
||||
resolve(connection);
|
||||
})
|
||||
.catch(err => {
|
||||
connection.destroy();
|
||||
reject(err);
|
||||
if (!this.client.options.patchVoice) {
|
||||
reject(
|
||||
new Error(
|
||||
'VOICE_NOT_PATCHED',
|
||||
'Enable voice patching in client options\nhttps://discordjs-self-v13.netlify.app/#/docs/docs/main/typedef/ClientOptions',
|
||||
),
|
||||
);
|
||||
} else {
|
||||
this.client.api
|
||||
.channels(this.id)
|
||||
.call.ring.post({
|
||||
data: {
|
||||
recipients: null,
|
||||
},
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Emit ring error:', e.message);
|
||||
});
|
||||
const connection = joinVoiceChannel({
|
||||
channelId: this.id,
|
||||
guildId: null,
|
||||
adapterCreator: this.voiceAdapterCreator,
|
||||
selfDeaf: options.selfDeaf ?? false,
|
||||
selfMute: options.selfMute ?? false,
|
||||
});
|
||||
entersState(connection, VoiceConnectionStatus.Ready, 30000)
|
||||
.then(connection => {
|
||||
resolve(connection);
|
||||
})
|
||||
.catch(err => {
|
||||
connection.destroy();
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@@ -311,31 +311,40 @@ class PartialGroupDMChannel extends Channel {
|
||||
*/
|
||||
call(options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.client.api
|
||||
.channels(this.id)
|
||||
.call.ring.post({
|
||||
body: {
|
||||
recipients: null,
|
||||
},
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Emit ring error:', e.message);
|
||||
});
|
||||
const connection = joinVoiceChannel({
|
||||
channelId: this.id,
|
||||
guildId: null,
|
||||
adapterCreator: this.voiceAdapterCreator,
|
||||
selfDeaf: options.selfDeaf ?? false,
|
||||
selfMute: options.selfMute ?? false,
|
||||
});
|
||||
entersState(connection, VoiceConnectionStatus.Ready, 30000)
|
||||
.then(connection => {
|
||||
resolve(connection);
|
||||
})
|
||||
.catch(err => {
|
||||
connection.destroy();
|
||||
reject(err);
|
||||
if (!this.client.options.patchVoice) {
|
||||
reject(
|
||||
new Error(
|
||||
'VOICE_NOT_PATCHED',
|
||||
'Enable voice patching in client options\nhttps://discordjs-self-v13.netlify.app/#/docs/docs/main/typedef/ClientOptions',
|
||||
),
|
||||
);
|
||||
} else {
|
||||
this.client.api
|
||||
.channels(this.id)
|
||||
.call.ring.post({
|
||||
body: {
|
||||
recipients: null,
|
||||
},
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Emit ring error:', e.message);
|
||||
});
|
||||
const connection = joinVoiceChannel({
|
||||
channelId: this.id,
|
||||
guildId: null,
|
||||
adapterCreator: this.voiceAdapterCreator,
|
||||
selfDeaf: options.selfDeaf ?? false,
|
||||
selfMute: options.selfMute ?? false,
|
||||
});
|
||||
entersState(connection, VoiceConnectionStatus.Ready, 30000)
|
||||
.then(connection => {
|
||||
resolve(connection);
|
||||
})
|
||||
.catch(err => {
|
||||
connection.destroy();
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@@ -38,7 +38,7 @@ const { randomUA } = require('../util/Constants');
|
||||
* @property {boolean} [checkUpdate=true] Display module update information on the screen
|
||||
* @property {boolean} [readyStatus=true] Sync state with Discord Client
|
||||
* @property {boolean} [autoCookie=true] Automatically add Cookies to Request on startup
|
||||
* @property {boolean} [patchVoice=true] Automatically patch @discordjs/voice module (support for call)
|
||||
* @property {boolean} [patchVoice=false] Automatically patch @discordjs/voice module (support for call)
|
||||
* @property {boolean} [autoRedeemNitro=false] Automaticlly redeems nitro codes <NOTE: there is no cooldown on the auto redeem>
|
||||
* @property {string} [proxy] Proxy to use for the WebSocket + REST connection (proxy-agent uri type) {@link https://www.npmjs.com/package/proxy-agent}.
|
||||
* @property {boolean} [DMSync=false] Automatically synchronize call status (DM and group) at startup (event synchronization) [Warning: May cause rate limit to gateway)
|
||||
@@ -149,7 +149,7 @@ class Options extends null {
|
||||
autoCookie: true,
|
||||
autoRedeemNitro: false,
|
||||
DMSync: false,
|
||||
patchVoice: true,
|
||||
patchVoice: false,
|
||||
waitGuildTimeout: 15_000,
|
||||
messageCreateEventGuildTimeout: 100,
|
||||
shardCount: 1,
|
||||
|
1443
src/util/Voice.js
1443
src/util/Voice.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user