the funny

This commit is contained in:
Lara 2024-11-02 14:55:29 +02:00
parent 5a555b7bb0
commit 09a573a2d3
Signed by: laratheprotogen
GPG key ID: 5C0296EB3165F98B
118 changed files with 15738 additions and 24427 deletions

View file

@ -3,7 +3,7 @@ import { GuildPluginData } from "knub";
import { allowTimeout } from "../../../RegExpRunner";
import { LogType } from "../../../data/LogType";
import { TypedTemplateSafeValueContainer } from "../../../templateFormatter";
import { MINUTES, isDiscordAPIError } from "../../../utils";
import { isDiscordAPIError, MINUTES, zSnowflake } from "../../../utils";
import { MessageBuffer } from "../../../utils/MessageBuffer";
import { InternalPosterPlugin } from "../../InternalPoster/InternalPosterPlugin";
import { ILogTypeData, LogsPluginType, TLogChannel, TLogChannelMap } from "../types";
@ -28,7 +28,11 @@ async function shouldExclude(
opts: TLogChannel,
exclusionData: ExclusionData,
): Promise<boolean> {
if (opts.excluded_users && exclusionData.userId && opts.excluded_users.includes(exclusionData.userId)) {
if (
opts.excluded_users &&
exclusionData.userId &&
opts.excluded_users.includes(zSnowflake.parse(exclusionData.userId))
) {
return true;
}
@ -38,21 +42,33 @@ async function shouldExclude(
if (opts.excluded_roles && exclusionData.roles) {
for (const role of exclusionData.roles) {
if (opts.excluded_roles.includes(role)) {
if (opts.excluded_roles.includes(await zSnowflake.parseAsync(role))) {
return true;
}
}
}
if (opts.excluded_channels && exclusionData.channel && opts.excluded_channels.includes(exclusionData.channel)) {
if (
opts.excluded_channels &&
exclusionData.channel &&
opts.excluded_channels.includes(await zSnowflake.parseAsync(exclusionData.channel))
) {
return true;
}
if (opts.excluded_categories && exclusionData.category && opts.excluded_categories.includes(exclusionData.category)) {
if (
opts.excluded_categories &&
exclusionData.category &&
opts.excluded_categories.includes(await zSnowflake.parseAsync(exclusionData.category))
) {
return true;
}
if (opts.excluded_threads && exclusionData.thread && opts.excluded_threads.includes(exclusionData.thread)) {
if (
opts.excluded_threads &&
exclusionData.thread &&
opts.excluded_threads.includes(await zSnowflake.parseAsync(exclusionData.thread))
) {
return true;
}
@ -83,20 +99,20 @@ export async function log<TLogType extends keyof ILogTypeData>(
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
if (!channel?.isTextBased()) continue;
if (pluginData.state.channelCooldowns.isOnCooldown(channelId)) continue;
if (opts.include?.length && !opts.include.includes(typeStr)) continue;
if (opts.exclude && opts.exclude.includes(typeStr)) continue;
if (await shouldExclude(pluginData, opts, exclusionData)) continue;
if (opts!.include?.length && !opts!.include.includes(typeStr)) continue;
if (opts!.exclude && opts!.exclude.includes(typeStr)) continue;
if (await shouldExclude(pluginData, opts!, exclusionData)) continue;
const message = await getLogMessage(pluginData, type, data, {
format: opts.format,
include_embed_timestamp: opts.include_embed_timestamp,
timestamp_format: opts.timestamp_format,
format: opts!.format,
include_embed_timestamp: opts!.include_embed_timestamp,
timestamp_format: opts!.timestamp_format,
});
if (!message) return;
// Initialize message buffer for this channel
if (!pluginData.state.buffers.has(channelId)) {
const batchTime = Math.min(Math.max(opts.batch_time ?? DEFAULT_BATCH_TIME, MIN_BATCH_TIME), MAX_BATCH_TIME);
const batchTime = Math.min(Math.max(opts!.batch_time ?? DEFAULT_BATCH_TIME, MIN_BATCH_TIME), MAX_BATCH_TIME);
const internalPosterPlugin = pluginData.getPlugin(InternalPosterPlugin);
pluginData.state.buffers.set(
channelId,