3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Finish preliminary rework, ready to test

This commit is contained in:
Dark 2021-06-02 04:07:50 +02:00
parent 57893e7f76
commit d0a1beb809
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
177 changed files with 854 additions and 707 deletions

View file

@ -17,6 +17,7 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
import { CaseTypes } from "../../../data/CaseTypes";
import { logger } from "../../../logger";
import humanizeDuration from "humanize-duration";
import { DiscordAPIError, User } from "discord.js";
/**
* Ban the specified user id, whether or not they're actually on the server at the time. Generates a case.
@ -77,14 +78,13 @@ export async function banUserId(
ignoreEvent(pluginData, IgnoredEventType.Ban, userId);
try {
const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1));
await pluginData.guild.banMember(
userId,
deleteMessageDays,
reason != null ? encodeURIComponent(reason) : undefined,
);
await pluginData.guild.bans.create(userId, {
days: deleteMessageDays,
reason: reason != null ? encodeURIComponent(reason) : undefined,
});
} catch (e) {
let errorMessage;
if (e instanceof DiscordRESTError) {
if (e instanceof DiscordAPIError) {
errorMessage = `API error ${e.code}: ${e.message}`;
} else {
logger.warn(`Error applying ban to ${userId}: ${e}`);