mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-12 23:59:34 -08:00
Webatrice admin commands (#5051)
* Add AdminCommand.updateServerMessage * Add AdminCommand.shutdownServer * Add AdminCommand.reloadConfig * Cleanup * Add AdminCommand.adjustMod * Lint * Lint
This commit is contained in:
29
webclient/src/websocket/commands/admin/shutdownServer.ts
Normal file
29
webclient/src/websocket/commands/admin/shutdownServer.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import webClient from '../../WebClient';
|
||||
import { AdminPersistence } from '../../persistence';
|
||||
|
||||
export function shutdownServer(reason: string, minutes: number): void {
|
||||
const command = webClient.protobuf.controller.Command_ShutdownServer.create({ reason, minutes });
|
||||
|
||||
const sc = webClient.protobuf.controller.AdminCommand.create({
|
||||
'.Command_ShutdownServer.ext': command
|
||||
});
|
||||
|
||||
webClient.protobuf.sendAdminCommand(sc, (raw) => {
|
||||
const { responseCode } = raw;
|
||||
|
||||
let error: string;
|
||||
|
||||
switch (responseCode) {
|
||||
case webClient.protobuf.controller.Response.ResponseCode.RespOk:
|
||||
AdminPersistence.shutdownServer();
|
||||
return;
|
||||
default:
|
||||
error = 'Failed to update server message.';
|
||||
break;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
console.error(responseCode, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user