mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Commands] Cleanup #delacct Command. (#2567)
- Cleanup messages and logic. - Use repositories.
This commit is contained in:
parent
19e7f0a6b1
commit
f143d0a75f
@ -118,7 +118,7 @@ int command_init(void)
|
||||
command_add("databuckets", "View|Delete [key] [limit]- View data buckets, limit 50 default or Delete databucket by key", AccountStatus::QuestTroupe, command_databuckets) ||
|
||||
command_add("date", "[Year] [Month] [Day] [Hour] [Minute] - Set EQ time (Hour and Minute are optional)", AccountStatus::EQSupport, command_date) ||
|
||||
command_add("dbspawn2", "[Spawngroup ID] [Respawn] [Variance] [Condition ID] [Condition Minimum] - Spawn an NPC from a predefined row in the spawn2 table, Respawn and Variance are in Seconds (condition is optional)", AccountStatus::GMAdmin, command_dbspawn2) ||
|
||||
command_add("delacct", "[accountname] - Delete an account", AccountStatus::GMLeadAdmin, command_delacct) ||
|
||||
command_add("delacct", "[Account ID|Account Name] - Delete an account by ID or Name", AccountStatus::GMLeadAdmin, command_delacct) ||
|
||||
command_add("delpetition", "[petition number] - Delete a petition", AccountStatus::ApprenticeGuide, command_delpetition) ||
|
||||
command_add("depop", "[Start Spawn Timer] - Depop your NPC target and optionally start their spawn timer (false by default)", AccountStatus::Guide, command_depop) ||
|
||||
command_add("depopzone", "[Start Spawn Timers] - Depop the zone and optionally start spawn timers (false by default)", AccountStatus::GMAdmin, command_depopzone) ||
|
||||
|
||||
@ -1,21 +1,75 @@
|
||||
#include "../client.h"
|
||||
#include "../../common/repositories/account_repository.h"
|
||||
|
||||
void command_delacct(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->arg[1][0] == 0) {
|
||||
c->Message(Chat::White, "Format: #delacct accountname");
|
||||
auto arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Format: #delacct [Account ID|Account Name]");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
std::string user;
|
||||
std::string loginserver;
|
||||
ParseAccountString(sep->arg[1], user, loginserver);
|
||||
|
||||
if (database.DeleteAccount(user.c_str(), loginserver.c_str())) {
|
||||
c->Message(Chat::White, "The account was deleted.");
|
||||
uint32 account_id = 0;
|
||||
std::string account_name;
|
||||
|
||||
if (sep->IsNumber(1)) {
|
||||
account_id = std::stoul(sep->arg[1]);
|
||||
auto a = AccountRepository::FindOne(content_db, account_id);
|
||||
if (!a.id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Account ID {} does not exist or is invalid.",
|
||||
account_id
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
c->Message(Chat::White, "Unable to delete account.");
|
||||
|
||||
account_name = a.name;
|
||||
} else {
|
||||
account_name = sep->arg[1];
|
||||
auto a = AccountRepository::GetWhere(
|
||||
content_db,
|
||||
fmt::format(
|
||||
"`name` = '{}'",
|
||||
account_name
|
||||
)
|
||||
);
|
||||
|
||||
if (a.empty() || !a[0].id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Account {} does not exist or is invalid.",
|
||||
account_name
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
account_id = a[0].id;
|
||||
}
|
||||
|
||||
if (!AccountRepository::DeleteOne(content_db, account_id)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Failed to delete account {} ({}).",
|
||||
account_name,
|
||||
account_id
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Successfully deleted account {} ({}).",
|
||||
account_name,
|
||||
account_id
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user