Update username and color command

This commit is contained in:
Hri7566 2024-02-23 17:14:28 -05:00
parent efa20e09ad
commit fe2c3a77da
1 changed files with 11 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import { Logger } from "@util/Logger";
import type Command from "./Command";
import { commandGroups } from "./groups";
import { createUser, getUser } from "@server/data/user";
import { createUser, getUser, updateUser } from "@server/data/user";
import { createInventory, getInventory } from "@server/data/inventory";
export const logger = new Logger("Command Handler");
@ -38,8 +38,17 @@ export async function handleCommand(
});
}
let inventory = await getInventory(user.inventoryId);
if (user.name !== part.name) {
user.name = part.name;
await updateUser(user);
}
if (user.color !== part.color) {
user.color = part.color;
await updateUser(user);
}
let inventory = await getInventory(user.inventoryId);
if (!inventory) inventory = await createInventory({ id: user.inventoryId });
// TODO Check user's (or their groups') permissions against command permission node