Add autocomplete finally
This commit is contained in:
parent
266cb22ce5
commit
435803134f
28
index.js
28
index.js
|
@ -254,7 +254,8 @@ client.on("ready", async () => {
|
|||
});
|
||||
|
||||
client.on("interactionCreate", async (interaction) => {
|
||||
if (!interaction.isCommand()) return;
|
||||
switch (interaction.type) {
|
||||
case Discord.InteractionType.ApplicationCommand:
|
||||
|
||||
switch (interaction.commandName) {
|
||||
case "register":
|
||||
|
@ -418,6 +419,31 @@ client.on("interactionCreate", async (interaction) => {
|
|||
});
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue