3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 22:01:50 +00:00

check props on run loop

This commit is contained in:
metal 2021-09-14 15:37:45 +00:00 committed by GitHub
parent 9406136861
commit b2755a754b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -15,12 +15,13 @@ export const ArchiveThreadAction = automodAction({
const threads = contexts
.filter((c) => c.message?.channel_id)
.map((c) => pluginData.guild.channels.cache.get(c.message!.channel_id))
.filter((c): c is ThreadChannel => (c?.isThread() && !c.archived) ?? false);
.filter((c): c is ThreadChannel => c?.isThread() ?? false);
for (const thread of threads) {
if (actionConfig.lock) {
if (actionConfig.lock && !thread.locked) {
await thread.setLocked().catch(noop);
}
if (thread.archived) continue;
await thread.setArchived().catch(noop);
}
},

View file

@ -15,12 +15,13 @@ export const UnArchiveThreadAction = automodAction({
const threads = contexts
.filter((c) => c.message?.channel_id)
.map((c) => pluginData.guild.channels.cache.get(c.message!.channel_id))
.filter((c): c is ThreadChannel => (c?.isThread() && c.archived) ?? false);
.filter((c): c is ThreadChannel => c?.isThread() ?? false);
for (const thread of threads) {
if (actionConfig.unlock) {
if (actionConfig.unlock && thread.locked) {
await thread.setLocked(false).catch(noop);
}
if (!thread.archived) continue;
await thread.setArchived(false).catch(noop);
}
},