Streamlined joining and leaving autocomplete

- Removed custom command builder as it's no longer needed with autocomplete
This commit is contained in:
Logan Cusano
2023-06-17 17:55:27 -04:00
parent f4475dc9d7
commit bfda15866e
4 changed files with 56 additions and 64 deletions

View File

@@ -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 })),
);
}