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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user