import { ApiCall } from "tsrpc";
import { Reqrename, Resrename } from "../../monopoly/protocols/union/Ptlrename";
import { GongHuiFun } from "../../public/gonghui/gonghui";
import { GHManage } from "../../public/gonghui/manage";

export default async function (call: ApiCall<Reqrename, Resrename>) {
    let _newName = call.req.guildName;
    await GongHuiFun.checkSetArgs({ name: _newName });

    let _GH = await GHManage.getGH(call.req.guildId);
    if (!_GH) {
        call.error('', { status: 1001, message: globalThis.lng.wucigonghui });
    }
    _GH.updateSetting({ name: _newName });

    call.succ({ status: 0, message: "success" });
}