- Add /cancel command to cancel an unverified account
This commit is contained in:
Christopher Cookman 2024-08-16 14:47:58 -06:00
parent bfbf63f15a
commit 266cb22ce5
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 25 additions and 0 deletions

View file

@ -68,5 +68,9 @@
"name": "list",
"description": "List all active accounts",
"type": 1
},
{
"name": "cancel",
"description": "Cancel verification and account number creation if you have one in-progress"
}
]

View file

@ -396,6 +396,27 @@ client.on("interactionCreate", async (interaction) => {
}
});
break;
case "cancel": // Cancel an unverified account
// Check if the user has an unverified account, if they do, delete it
db.get("SELECT * FROM accounts WHERE discord_id = ? AND verified = 0", interaction.user.id, (err, row) => {
if (err) {
console.error(err);
} else if (row) {
db.run("DELETE FROM accounts WHERE discord_id = ? AND verified = 0", interaction.user.id, (err) => {
if (err) {
console.error(err);
} else {
interaction.reply({
content: "Account creation cancelled.",
ephemeral: true
});
}
});
} else {
interaction.reply({ content: "You don't have an unverified account.", ephemeral: true });
}
});
break;
}
});