mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Improve !ban error messages
This commit is contained in:
parent
f4fc46d6eb
commit
fec2b49129
2 changed files with 12 additions and 3 deletions
|
@ -98,7 +98,7 @@ export const BanCmd = modActionsCmd({
|
||||||
});
|
});
|
||||||
|
|
||||||
if (banResult.status === "failed") {
|
if (banResult.status === "failed") {
|
||||||
sendErrorMessage(pluginData, msg.channel, `Failed to ban member`);
|
sendErrorMessage(pluginData, msg.channel, `Failed to ban member: ${banResult.error}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,14 @@ import {
|
||||||
ucfirst,
|
ucfirst,
|
||||||
UserNotificationResult,
|
UserNotificationResult,
|
||||||
} from "../../../utils";
|
} from "../../../utils";
|
||||||
import { User } from "eris";
|
import { DiscordRESTError, User } from "eris";
|
||||||
import { renderTemplate } from "../../../templateFormatter";
|
import { renderTemplate } from "../../../templateFormatter";
|
||||||
import { getDefaultContactMethods } from "./getDefaultContactMethods";
|
import { getDefaultContactMethods } from "./getDefaultContactMethods";
|
||||||
import { LogType } from "../../../data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { ignoreEvent } from "./ignoreEvent";
|
import { ignoreEvent } from "./ignoreEvent";
|
||||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes";
|
import { CaseTypes } from "../../../data/CaseTypes";
|
||||||
|
import { logger } from "../../../logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ban the specified user id, whether or not they're actually on the server at the time. Generates a case.
|
* Ban the specified user id, whether or not they're actually on the server at the time. Generates a case.
|
||||||
|
@ -69,9 +70,17 @@ export async function banUserId(
|
||||||
reason != null ? encodeURIComponent(reason) : undefined,
|
reason != null ? encodeURIComponent(reason) : undefined,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
let errorMessage;
|
||||||
|
if (e instanceof DiscordRESTError) {
|
||||||
|
errorMessage = `API error ${e.code}: ${e.message}`;
|
||||||
|
} else {
|
||||||
|
logger.warn(`Error applying ban to ${userId}: ${e}`);
|
||||||
|
errorMessage = "Unknown error";
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: "failed",
|
status: "failed",
|
||||||
error: e.message,
|
error: errorMessage,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue