diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-26 16:12:11 +0000 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-26 16:12:11 +0000 |
commit | 973bbebfd0a47b0b36d19fccf6a882e971beaaa5 (patch) | |
tree | 39dc606816ed198735a7ed0669a195f64e6a06c6 /src/lib/common/HighlightManager.ts | |
parent | 00ad00734ddb2c2fce8de8efcc010181c9ce1821 (diff) | |
parent | a9ac478ee06f9567f3fde73f777da88c6b876c4f (diff) | |
download | tanzanite-973bbebfd0a47b0b36d19fccf6a882e971beaaa5.tar.gz tanzanite-973bbebfd0a47b0b36d19fccf6a882e971beaaa5.tar.bz2 tanzanite-973bbebfd0a47b0b36d19fccf6a882e971beaaa5.zip |
Merge branch 'master' of https://github.com/NotEnoughUpdates/bush-bot-3.0
Diffstat (limited to 'src/lib/common/HighlightManager.ts')
-rw-r--r-- | src/lib/common/HighlightManager.ts | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/lib/common/HighlightManager.ts b/src/lib/common/HighlightManager.ts index 6194255..83506bc 100644 --- a/src/lib/common/HighlightManager.ts +++ b/src/lib/common/HighlightManager.ts @@ -24,7 +24,15 @@ export class HighlightManager { */ public readonly userBlocks = new Collection< /* guild */ Snowflake, - Collection</* word */ Snowflake, /* users */ Set<Snowflake>> + Collection</* user */ Snowflake, /* users */ Set<Snowflake>> + >(); + + /** + * Channels that users have blocked + */ + public readonly channelBlocks = new Collection< + /* guild */ Snowflake, + Collection</* user */ Snowflake, /* channels */ Set<Snowflake>> >(); /** @@ -66,7 +74,17 @@ export class HighlightManager { for (const [word, users] of guildCache.entries()) { if (this.isMatch(message.content, word)) { for (const user of users) { - if (!ret.has(user)) ret.set(user, word); + if (!ret.has(user)) { + if (!message.channel.permissionsFor(user)?.has('ViewChannel')) continue; + + const blockedUsers = this.userBlocks.get(message.guildId)?.get(user) ?? new Set(); + if (blockedUsers.has(message.author.id)) continue; + + const blockedChannels = this.channelBlocks.get(message.guildId)?.get(user) ?? new Set(); + if (blockedChannels.has(message.channel.id)) continue; + + ret.set(user, word); + } } } } |