mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-09-22 22:27:56 +03:00
Avoid to use $.content, Changes on WebUI
* Fix mistake that i was put webui handler on models folder * Cahnge WebUI name.
This commit is contained in:
@@ -745,25 +745,25 @@ export const savePlayer: EPR = async (info, data, send) => {
|
||||
|
||||
const autoSet = (field: keyof Profile, path: string, array = false): void => {
|
||||
if (array) {
|
||||
profile[field] = dataplayer.content(path, profile[field])
|
||||
profile[field] = dataplayer.numbers(path, profile[field])
|
||||
} else {
|
||||
profile[field] = dataplayer.content(path, profile[field])[0]
|
||||
profile[field] = dataplayer.number(path, profile[field])
|
||||
}
|
||||
};
|
||||
|
||||
const autoExtra = (field: keyof Extra, path: string, array = false): void => {
|
||||
if (array) {
|
||||
extra[field] = dataplayer.content(path, extra[field])
|
||||
extra[field] = dataplayer.numbers(path, extra[field])
|
||||
} else {
|
||||
extra[field] = dataplayer.content(path, extra[field])[0]
|
||||
extra[field] = dataplayer.number(path, extra[field])
|
||||
}
|
||||
};
|
||||
|
||||
const autoRec = (field: keyof Record, path: string, array = false): void => {
|
||||
if (array) {
|
||||
rec[field] = dataplayer.content(path, rec[field])
|
||||
rec[field] = dataplayer.numbers(path, rec[field])
|
||||
} else {
|
||||
rec[field] = dataplayer.content(path, rec[field])[0]
|
||||
rec[field] = dataplayer.number(path, rec[field])
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { PlayerInfo } from "../models/playerinfo"
|
||||
|
||||
export const updatePlayerInfo = async (data: {
|
||||
refid: string;
|
||||
version: string;
|
||||
name?: string;
|
||||
title?: string;
|
||||
}) => {
|
||||
if (data.refid == null) return;
|
||||
|
||||
const update: Update<PlayerInfo>['$set'] = {};
|
||||
|
||||
if (data.name && data.name.length > 0) {
|
||||
//TODO: name validator
|
||||
update.name = data.name;
|
||||
}
|
||||
|
||||
if (data.title && data.title.length > 0) {
|
||||
//TODO: title validator
|
||||
update.title = data.title;
|
||||
}
|
||||
|
||||
await DB.Update<PlayerInfo>(
|
||||
data.refid,
|
||||
{ collection: 'playerinfo', version: data.version },
|
||||
{ $set: update }
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user