Closes #1074 Based on what I could find, apparently only rooms need 2 hours to destroy and decos are removed instantly. Reviewed-on: #1089
19 lines
853 B
TypeScript
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 };
|