3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-11 04:57:19 +00:00

remove cache check

This commit is contained in:
metal 2021-10-18 15:26:05 +00:00 committed by GitHub
parent 321a9c0a00
commit a78a0ac1b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,18 +22,19 @@ export const StartThreadAction = automodAction({
async apply({ pluginData, contexts, actionConfig, ruleName }) { async apply({ pluginData, contexts, actionConfig, ruleName }) {
// check if the message still exists, we don't want to create threads for deleted messages // check if the message still exists, we don't want to create threads for deleted messages
const threads = contexts.filter(c => { const threads = contexts.filter((c) => {
if (!c.message || !c.user) return false; if (!c.message || !c.user) return false;
const channel = pluginData.guild.channels.cache.get(c.message.channel_id); const channel = pluginData.guild.channels.cache.get(c.message.channel_id);
if (channel?.type !== ChannelTypeStrings.TEXT || !channel.isText()) return false; // for some reason the typing here for channel.type defaults to ThreadChannelTypes (?) if (channel?.type !== ChannelTypeStrings.TEXT || !channel.isText()) return false; // for some reason the typing here for channel.type defaults to ThreadChannelTypes (?)
// check against max threads per channel // check against max threads per channel
if (actionConfig.limit_per_channel && actionConfig.limit_per_channel > 0) { if (actionConfig.limit_per_channel && actionConfig.limit_per_channel > 0) {
const threadCount = channel.threads.cache.filter( const threadCount = channel.threads.cache.filter(
tr => tr.ownerId === pluginData.client.user!.id && !tr.deleted && !tr.archived && tr.parentId === channel.id, (tr) =>
tr.ownerId === pluginData.client.user!.id && !tr.deleted && !tr.archived && tr.parentId === channel.id,
).size; ).size;
if (threadCount >= actionConfig.limit_per_channel) return false; if (threadCount >= actionConfig.limit_per_channel) return false;
} }
return channel.messages.cache.has(c.message.id); return true;
}); });
const guild = pluginData.guild; const guild = pluginData.guild;