mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 04:45:02 +00:00
Centralize DM logic, don't attempt DMs for an hour after a 20026 error
This commit is contained in:
parent
1d4c32d8f9
commit
902be16ae8
5 changed files with 60 additions and 16 deletions
|
@ -38,6 +38,8 @@ import moment from "moment-timezone";
|
|||
import { SimpleCache } from "./SimpleCache";
|
||||
import { logger } from "./logger";
|
||||
import { unsafeCoerce } from "fp-ts/lib/function";
|
||||
import { sendDM } from "./utils/sendDM";
|
||||
import { LogType } from "./data/LogType";
|
||||
|
||||
const fsp = fs.promises;
|
||||
|
||||
|
@ -878,9 +880,7 @@ export async function notifyUser(
|
|||
for (const method of methods) {
|
||||
if (method.type === "dm") {
|
||||
try {
|
||||
console.log(`Notifying user ${user.id} via DM`);
|
||||
const dmChannel = await user.getDMChannel();
|
||||
await dmChannel.createMessage(body);
|
||||
await sendDM(user, body, "mod action notification");
|
||||
return {
|
||||
method,
|
||||
success: true,
|
||||
|
@ -1069,8 +1069,6 @@ export async function resolveMember(bot: Client, guild: Guild, value: string): P
|
|||
return null;
|
||||
}
|
||||
|
||||
logger.debug(`Fetching unknown member (${userId} in ${guild.name} (${guild.id})) from the API`);
|
||||
|
||||
const freshMember = await bot.getRESTGuildMember(guild.id, userId).catch(noop);
|
||||
if (freshMember) {
|
||||
freshMember.id = userId;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue