Streamlined joining and leaving autocomplete
- Removed custom command builder as it's no longer needed with autocomplete
This commit is contained in:
@@ -3,6 +3,7 @@ const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||
const { clientObject } = require("./recordHelper");
|
||||
const { readFileSync } = require('fs');
|
||||
const log = new DebugBuilder("server", "utils");
|
||||
const logAC = new DebugBuilder("server", "command-autocorrect");
|
||||
const path = require('path');
|
||||
|
||||
// Convert a JSON object to a buffer for the DB
|
||||
@@ -116,4 +117,20 @@ exports.getClientObjectByClientID = (clientId) => {
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
|
||||
exports.filterAutocompleteValues = async (interaction, options) => {
|
||||
// Get the command used
|
||||
const command = interaction.command;
|
||||
|
||||
// Find values that start with what the user is entering
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const filtered = options.filter(preset => preset.startsWith(focusedValue));
|
||||
|
||||
// Give the query response to the user
|
||||
logAC.DEBUG("Focused Value: ", command, focusedValue, options, filtered);
|
||||
await interaction.respond(
|
||||
filtered.map(option => ({ name: option, value: option })),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user