Ugly workaround/hotfix for message fetching

This commit is contained in:
Dragory 2021-08-19 00:49:06 +03:00
parent 499511f79d
commit 8da47e53e6
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
9 changed files with 31 additions and 14 deletions

View file

@ -11,6 +11,7 @@ import { LogsPlugin } from "../../Logs/LogsPlugin";
import { BOT_SLOWMODE_PERMISSIONS } from "../requiredPermissions";
import { SlowmodePluginType } from "../types";
import { applyBotSlowmodeToUserId } from "./applyBotSlowmodeToUserId";
import { hotfixMessageFetch } from "../../../utils/hotfixMessageFetch";
export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) {
if (msg.is_bot) return;
@ -49,7 +50,7 @@ export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePlugin
// Delete any extra messages sent after a slowmode was already applied
const userHasSlowmode = await pluginData.state.slowmodes.userHasSlowmode(channel.id, msg.user_id);
if (userHasSlowmode) {
const message = await channel.messages.fetch(msg.id as Snowflake);
const message = await hotfixMessageFetch(channel, msg.id);
if (message) {
message.delete();
return thisMsgLock.interrupt();