mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +00:00
fix: don't attempt to message users off-server
Co-authored-by: metal0 <metal@i0.tf>
This commit is contained in:
parent
dd2eebd4a5
commit
dd1afc4dab
3 changed files with 10 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
|||
import { DiscordAPIError, Snowflake, User } from "discord.js";
|
||||
import { DiscordAPIError, Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
@ -10,6 +10,7 @@ import {
|
|||
createUserNotificationError,
|
||||
DAYS,
|
||||
notifyUser,
|
||||
resolveMember,
|
||||
resolveUser,
|
||||
SECONDS,
|
||||
ucfirst,
|
||||
|
@ -42,8 +43,9 @@ export async function banUserId(
|
|||
}
|
||||
|
||||
// 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 && user instanceof User) {
|
||||
if (reason && member) {
|
||||
const contactMethods = banOptions?.contactMethods
|
||||
? banOptions.contactMethods
|
||||
: getDefaultContactMethods(pluginData, "ban");
|
||||
|
@ -61,7 +63,7 @@ export async function banUserId(
|
|||
}),
|
||||
);
|
||||
|
||||
notifyResult = await notifyUser(user, banMessage, contactMethods);
|
||||
notifyResult = await notifyUser(member.user, banMessage, contactMethods);
|
||||
} else if (banTime && config.tempban_message) {
|
||||
const banMessage = await renderTemplate(
|
||||
config.tempban_message,
|
||||
|
@ -75,7 +77,7 @@ export async function banUserId(
|
|||
}),
|
||||
);
|
||||
|
||||
notifyResult = await notifyUser(user, banMessage, contactMethods);
|
||||
notifyResult = await notifyUser(member.user, banMessage, contactMethods);
|
||||
} else {
|
||||
notifyResult = createUserNotificationError("No ban/tempban message specified in config");
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export async function kickMember(
|
|||
|
||||
// Attempt to message the user *before* kicking them, as doing it after may not be possible
|
||||
let notifyResult: UserNotificationResult = { method: null, success: true };
|
||||
if (reason) {
|
||||
if (reason && member) {
|
||||
const contactMethods = kickOptions?.contactMethods
|
||||
? kickOptions.contactMethods
|
||||
: getDefaultContactMethods(pluginData, "kick");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake, User } from "discord.js";
|
||||
import { Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
@ -191,7 +191,7 @@ export async function muteUser(
|
|||
}),
|
||||
));
|
||||
|
||||
if (muteMessage && user instanceof User) {
|
||||
if (muteMessage && member) {
|
||||
let contactMethods: UserNotificationMethod[] = [];
|
||||
|
||||
if (muteOptions?.contactMethods) {
|
||||
|
@ -211,7 +211,7 @@ export async function muteUser(
|
|||
}
|
||||
}
|
||||
|
||||
notifyResult = await notifyUser(user, muteMessage, contactMethods);
|
||||
notifyResult = await notifyUser(member.user, muteMessage, contactMethods);
|
||||
}
|
||||
|
||||
// Create/update a case
|
||||
|
|
Loading…
Add table
Reference in a new issue