mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-16 22:55:03 +00:00
Merge 8da0529b60
into eb5fda8d19
This commit is contained in:
commit
c1032fd43b
6 changed files with 32 additions and 8 deletions
|
@ -33,7 +33,6 @@ export async function banUserId(
|
|||
banOptions: BanOptions = {},
|
||||
banTime?: number,
|
||||
): Promise<BanResult> {
|
||||
const config = pluginData.config.get();
|
||||
const user = await resolveUser(pluginData.client, userId);
|
||||
if (!user.id) {
|
||||
return {
|
||||
|
@ -42,10 +41,13 @@ export async function banUserId(
|
|||
};
|
||||
}
|
||||
|
||||
const config = pluginData.config.get();
|
||||
reason ||= config.default_reasons?.ban || "No reason specified";
|
||||
|
||||
// Attempt to message the user *before* banning them, as doing it after may not be possible
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, userId);
|
||||
let notifyResult: UserNotificationResult = { method: null, success: true };
|
||||
if (reason && member) {
|
||||
if (member) {
|
||||
const contactMethods = banOptions?.contactMethods
|
||||
? banOptions.contactMethods
|
||||
: getDefaultContactMethods(pluginData, "ban");
|
||||
|
@ -113,7 +115,7 @@ export async function banUserId(
|
|||
const deleteMessageDays = Math.min(7, Math.max(0, banOptions.deleteMessageDays ?? 1));
|
||||
await pluginData.guild.bans.create(userId as Snowflake, {
|
||||
deleteMessageSeconds: (deleteMessageDays * DAYS) / SECONDS,
|
||||
reason: reason ?? undefined,
|
||||
reason,
|
||||
});
|
||||
} catch (e) {
|
||||
let errorMessage;
|
||||
|
@ -171,7 +173,7 @@ export async function banUserId(
|
|||
mod,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason: reason ?? "",
|
||||
reason,
|
||||
banTime: humanizeDuration(banTime),
|
||||
});
|
||||
} else {
|
||||
|
@ -179,7 +181,7 @@ export async function banUserId(
|
|||
mod,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason: reason ?? "",
|
||||
reason,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue