SpaceNinjaServer/src/controllers/api/setDojoComponentMessageController.ts
Sainan 77aa1caa8f
All checks were successful
Build / build (20) (push) Successful in 38s
Build / build (18) (push) Successful in 57s
Build / build (22) (push) Successful in 56s
Build Docker image / docker (push) Successful in 39s
feat: dojo room destruction stage (#1089)
Closes #1074

Based on what I could find, apparently only rooms need 2 hours to destroy and decos are removed instantly.

Reviewed-on: #1089
2025-03-06 07:19:01 -08:00

19 lines
853 B
TypeScript

import { RequestHandler } from "express";
import { getDojoClient, getGuildForRequest } from "@/src/services/guildService";
export const setDojoComponentMessageController: RequestHandler = async (req, res) => {
const guild = await getGuildForRequest(req);
// At this point, we know that a member of the guild is making this request. Assuming they are allowed to change the message.
const component = guild.DojoComponents.id(req.query.componentId as string)!;
const payload = JSON.parse(String(req.body)) as SetDojoComponentMessageRequest;
if ("Name" in payload) {
component.Name = payload.Name;
} else {
component.Message = payload.Message;
}
await guild.save();
res.json(await getDojoClient(guild, 0, component._id));
};
type SetDojoComponentMessageRequest = { Name: string } | { Message: string };