mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
fix(automod): fetch message user/member if missing from cache
This commit is contained in:
parent
ac3073d3a2
commit
3131878cfb
1 changed files with 7 additions and 3 deletions
|
@ -8,13 +8,17 @@ import { runAutomod } from "../functions/runAutomod";
|
|||
import { AutomodContext, AutomodPluginType } from "../types";
|
||||
import { performance } from "perf_hooks";
|
||||
|
||||
export function runAutomodOnMessage(
|
||||
export async function runAutomodOnMessage(
|
||||
pluginData: GuildPluginData<AutomodPluginType>,
|
||||
message: SavedMessage,
|
||||
isEdit: boolean,
|
||||
) {
|
||||
const user = pluginData.client.users.cache.get(message.user_id as Snowflake);
|
||||
const member = pluginData.guild.members.cache.get(message.user_id as Snowflake);
|
||||
const member =
|
||||
pluginData.guild.members.cache.get(message.user_id) ??
|
||||
(await pluginData.guild.members.fetch(message.user_id).catch(() => undefined));
|
||||
const user =
|
||||
pluginData.client.users.cache.get(message.user_id) ??
|
||||
(await pluginData.client.users.fetch(message.user_id).catch(() => undefined));
|
||||
|
||||
const context: AutomodContext = {
|
||||
timestamp: moment.utc(message.posted_at).valueOf(),
|
||||
|
|
Loading…
Add table
Reference in a new issue