aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-25 23:03:02 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-25 23:03:02 -0500
commit866cd2c23eaa3918d01806556ea71f6c7b378ca7 (patch)
tree1d4f4ca50bb15996ad60ad36ec2cea2bc6b8ef4c
parent1d6e64d5c43e4398e7c0488f114acba2c8a55164 (diff)
downloadtanzanite-866cd2c23eaa3918d01806556ea71f6c7b378ca7.tar.gz
tanzanite-866cd2c23eaa3918d01806556ea71f6c7b378ca7.tar.bz2
tanzanite-866cd2c23eaa3918d01806556ea71f6c7b378ca7.zip
fix: misc
-rw-r--r--.vscode/extensions.json3
-rw-r--r--src/lib/common/HighlightManager.ts22
-rw-r--r--src/listeners/message/highlight.ts2
3 files changed, 23 insertions, 4 deletions
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 5722024..a7bd4bb 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -9,6 +9,7 @@
"github.vscode-pull-request-github",
"ckolkman.vscode-postgres",
"tobias-faller.vt100-syntax-highlighting",
- "pkief.material-icon-theme"
+ "pkief.material-icon-theme",
+ "Tobias-Faller.vt100-syntax-highlighting"
]
}
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);
+ }
}
}
}
diff --git a/src/listeners/message/highlight.ts b/src/listeners/message/highlight.ts
index d3d7bfb..c751ad5 100644
--- a/src/listeners/message/highlight.ts
+++ b/src/listeners/message/highlight.ts
@@ -11,7 +11,7 @@ export default class HighlightListener extends BushListener {
public override async exec(...[message]: BushClientEvents['messageCreate']) {
if (!message.inGuild()) return;
- if (message.author.bot) return;
+ if (message.author.bot || message.system) return;
if (!(await message.guild.hasFeature('highlight'))) return; // allows highlighting to be disabled on a guild-by-guild basis
const res = client.highlightManager.checkMessage(message);