Add autocomplete finally

This commit is contained in:
Christopher Cookman 2024-08-16 14:54:19 -06:00
parent 266cb22ce5
commit 435803134f
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -254,7 +254,8 @@ client.on("ready", async () => {
}); });
client.on("interactionCreate", async (interaction) => { client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return; switch (interaction.type) {
case Discord.InteractionType.ApplicationCommand:
switch (interaction.commandName) { switch (interaction.commandName) {
case "register": case "register":
@ -418,6 +419,31 @@ client.on("interactionCreate", async (interaction) => {
}); });
break; break;
} }
break;
case Discord.InteractionType.ApplicationCommandAutocomplete:
switch (interaction.commandName) {
case "deactivate":
// Get all active accounts owned by the user
db.all("SELECT * FROM accounts WHERE discord_id = ? AND verified = 1", interaction.user.id, (err, rows) => {
if (err) {
console.error(err);
} else if (rows) {
let accountList = [];
rows.forEach((row) => {
accountList.push({
name: `${row.id} - ${row.phone}`,
value: row.id
});
});
interaction.respond({
choices: accountList
});
}
});
break;
}
break;
}
}); });