mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Suspects: Fix loginserver error handling
This commit is contained in:
parent
8f91863968
commit
5bec49f7a0
|
|
@ -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}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user