mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 20:55:01 +00:00
feat: add thread_create and thread_delete automod triggers (#272)
Co-authored-by: metal <admin@metalruller.com>
This commit is contained in:
parent
6e3a6249c7
commit
92dfbca362
7 changed files with 177 additions and 5 deletions
|
@ -15,9 +15,11 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
|||
const member = context.member || (userId && pluginData.guild.members.cache.get(userId as Snowflake)) || null;
|
||||
|
||||
const channelIdOrThreadId = context.message?.channel_id;
|
||||
const channelOrThread = channelIdOrThreadId
|
||||
? (pluginData.guild.channels.cache.get(channelIdOrThreadId as Snowflake) as TextChannel | ThreadChannel)
|
||||
: null;
|
||||
const channelOrThread =
|
||||
context.channel ??
|
||||
(channelIdOrThreadId
|
||||
? (pluginData.guild.channels.cache.get(channelIdOrThreadId as Snowflake) as TextChannel | ThreadChannel)
|
||||
: null);
|
||||
const channelId = channelOrThread?.isThread() ? channelOrThread.parent?.id : channelIdOrThreadId;
|
||||
const threadId = channelOrThread?.isThread() ? channelOrThread.id : null;
|
||||
const channel = channelOrThread?.isThread() ? channelOrThread.parent : channelOrThread;
|
||||
|
@ -33,7 +35,15 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
|||
|
||||
for (const [ruleName, rule] of Object.entries(config.rules)) {
|
||||
if (rule.enabled === false) continue;
|
||||
if (!rule.affects_bots && (!user || user.bot) && !context.counterTrigger && !context.antiraid) continue;
|
||||
if (
|
||||
!rule.affects_bots &&
|
||||
(!user || user.bot) &&
|
||||
!context.counterTrigger &&
|
||||
!context.antiraid &&
|
||||
!context.threadChange?.deleted
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (!rule.affects_self && userId && userId === pluginData.client.user?.id) continue;
|
||||
|
||||
if (rule.cooldown && checkAndUpdateCooldown(pluginData, rule, context)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue