Update
- Deps: + `discord-api-types`: `0.37.8` > `0.37.10` + `ws`: `8.8.1` > `8.9.0` + `string-similarity`: `4.0.4` - Dev deps: + `eslint`: `8.23.0` > `8.24.0` - Update @discordjs/voice - fix(SendSlash): Error when fetch autocomplete data - fix(MessageButton): Circular Dependencies
This commit is contained in:
parent
7defc76498
commit
11e2798ae5
@ -62,14 +62,15 @@
|
||||
"axios": "^0.27.2",
|
||||
"bignumber.js": "^9.1.0",
|
||||
"chalk": "^4.1.2",
|
||||
"discord-api-types": "^0.37.8",
|
||||
"discord-api-types": "^0.37.10",
|
||||
"form-data": "^4.0.0",
|
||||
"json-bigint": "^1.0.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"proxy-agent": "^5.0.0",
|
||||
"safe-base64": "^2.0.1-0",
|
||||
"string_decoder": "^1.3.0",
|
||||
"ws": "^8.8.1"
|
||||
"string-similarity": "^4.0.4",
|
||||
"ws": "^8.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.6.0",
|
||||
@ -83,7 +84,7 @@
|
||||
"@types/node": "^16.11.12",
|
||||
"conventional-changelog-cli": "^2.2.2",
|
||||
"dtslint": "^4.2.1",
|
||||
"eslint": "^8.23.0",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-import": "^2.25.3",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
|
@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
let ClientUser;
|
||||
const { VoiceConnection, VoiceConnectionStatus } = require('@discordjs/voice');
|
||||
const { VoiceConnection } = require('@discordjs/voice');
|
||||
const axios = require('axios');
|
||||
const chalk = require('chalk');
|
||||
const Discord = require('../../../index');
|
||||
const { Events, Opcodes } = require('../../../util/Constants');
|
||||
const { Networking } = require('../../../util/Voice');
|
||||
const { VoiceConnection: VoiceConnection_patch } = require('../../../util/Voice');
|
||||
let running = false;
|
||||
/**
|
||||
* Emitted whenever clientOptions.checkUpdate = false
|
||||
@ -66,35 +66,7 @@ module.exports = async (client, { d: data }, shard) => {
|
||||
|
||||
if (client.options.patchVoice && !running) {
|
||||
/* eslint-disable */
|
||||
VoiceConnection.prototype.configureNetworking = function () {
|
||||
const { server, state } = this.packets;
|
||||
if (
|
||||
!server ||
|
||||
!state ||
|
||||
this.state.status === VoiceConnectionStatus.Destroyed /* Destroyed */ ||
|
||||
!server.endpoint
|
||||
)
|
||||
return;
|
||||
const networking = new Networking(
|
||||
{
|
||||
endpoint: server.endpoint,
|
||||
serverId: server.guild_id ?? server.channel_id,
|
||||
token: server.token,
|
||||
sessionId: state.session_id,
|
||||
userId: state.user_id,
|
||||
},
|
||||
Boolean(this.debug),
|
||||
);
|
||||
networking.once('close', this.onNetworkingClose);
|
||||
networking.on('stateChange', this.onNetworkingStateChange);
|
||||
networking.on('error', this.onNetworkingError);
|
||||
networking.on('debug', this.onNetworkingDebug);
|
||||
this.state = {
|
||||
...this.state,
|
||||
status: VoiceConnectionStatus.Connecting /* Connecting */,
|
||||
networking,
|
||||
};
|
||||
};
|
||||
VoiceConnection.prototype.configureNetworking = VoiceConnection_patch.prototype.configureNetworking;
|
||||
client.emit(
|
||||
Events.DEBUG,
|
||||
`${chalk.greenBright('[OK]')} Patched ${chalk.cyanBright(
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { setTimeout } = require('node:timers');
|
||||
const { findBestMatch } = require('string-similarity');
|
||||
const Base = require('./Base');
|
||||
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
||||
const MessageAttachment = require('../structures/MessageAttachment');
|
||||
@ -830,8 +831,17 @@ class ApplicationCommand extends Base {
|
||||
clearTimeout(timeout);
|
||||
this.client.removeListener(Events.APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, handler);
|
||||
this.client.decrementMaxListeners();
|
||||
if (data.choices.length > 1) resolve(data.choices[0].value);
|
||||
else resolve(value);
|
||||
if (data.choices.length > 1) {
|
||||
// Find best match name
|
||||
const bestMatch = findBestMatch(
|
||||
value,
|
||||
data.choices.map(c => c.name),
|
||||
);
|
||||
const result = data.choices.find(c => c.name == bestMatch.bestMatch.target);
|
||||
resolve(result.value);
|
||||
} else {
|
||||
resolve(value);
|
||||
}
|
||||
};
|
||||
const timeout = setTimeout(() => {
|
||||
this.client.removeListener(Events.APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, handler);
|
||||
|
@ -2,11 +2,12 @@
|
||||
|
||||
const { setTimeout } = require('node:timers');
|
||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const { Message } = require('./Message');
|
||||
const { RangeError } = require('../errors');
|
||||
const { MessageButtonStyles, MessageComponentTypes } = require('../util/Constants');
|
||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
const Util = require('../util/Util');
|
||||
const { lazy } = require('../util/Util');
|
||||
const Message = lazy(() => require('../structures/Message').Message);
|
||||
|
||||
/**
|
||||
* Represents a button message component.
|
||||
@ -171,7 +172,7 @@ class MessageButton extends BaseMessageComponent {
|
||||
*/
|
||||
async click(message) {
|
||||
const nonce = SnowflakeUtil.generate();
|
||||
if (!(message instanceof Message)) throw new Error('[UNKNOWN_MESSAGE] Please pass a valid Message');
|
||||
if (!(message instanceof Message())) throw new Error('[UNKNOWN_MESSAGE] Please pass a valid Message');
|
||||
if (!this.customId || this.style == 5 || this.disabled) return false; // Button URL, Disabled
|
||||
await message.client.api.interactions.post({
|
||||
data: {
|
||||
|
1684
src/util/Voice.js
1684
src/util/Voice.js
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user