diff --git a/server/chat-plugins/suspect-tests.ts b/server/chat-plugins/suspect-tests.ts index de8bc5c870..53bfe8fe37 100644 --- a/server/chat-plugins/suspect-tests.ts +++ b/server/chat-plugins/suspect-tests.ts @@ -100,12 +100,14 @@ export const commands: Chat.ChatCommands = { reqData[k] = val; } - const [, error] = await LoginServer.request("suspects/add", { + const [out, error] = await LoginServer.request("suspects/add", { format: format.id, reqs: JSON.stringify(reqData), url: urlActual, }); - if (error) throw new Chat.ErrorMessage("Error adding suspect test: " + error.message); + if (out?.actionerror || error) { + throw new Chat.ErrorMessage("Error adding suspect test: " + (out?.actionerror || error.message)); + } this.privateGlobalModAction(`${user.name} ${suspectTests.suspects[format.id] ? "edited the" : "added a"} ${format.name} suspect test.`); this.globalModlog('SUSPECTTEST', null, `${suspectTests.suspects[format.id] ? "edited" : "added"} ${format.name}`); @@ -130,10 +132,12 @@ export const commands: Chat.ChatCommands = { const test = suspectTests.suspects[format]; if (!test) return this.errorReply(`There is no suspect test for '${target}'. Check spelling?`); - const [, error] = await LoginServer.request('suspects/end', { + const [out, error] = await LoginServer.request('suspects/end', { format, }); - if (error) throw new Chat.ErrorMessage(`Error ending suspect: ${error.message}`); + if (out?.actionerror || error) { + throw new Chat.ErrorMessage(`Error ending suspect: ${out?.actionerror || error?.message}`); + } this.privateGlobalModAction(`${user.name} removed the ${test.tier} suspect test.`); this.globalModlog('SUSPECTTEST', null, `removed ${test.tier}`);