Skip to content

Commit 3e4746f

Browse files
authored
added ignore list for autothread channels to stop odd behaviour (#515)
1 parent ca53165 commit 3e4746f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/features/x-cancel-generator.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
1+
import { CHANNELS } from "../constants/channels.js";
12
import type { ChannelHandlers } from "../types/index.js";
23

34
export const TWITTER_REGEX =
45
/https?:\/\/(?:www\.)?(?:x|twitter)\.com\/\w+\/status\/\d+/i;
56

7+
const THREAD_CHANNELS = [
8+
CHANNELS.events,
9+
CHANNELS.iBuiltThis,
10+
CHANNELS.iWroteThis,
11+
CHANNELS.techReadsAndNews,
12+
CHANNELS.twitterFeed,
13+
];
614
const xCancelGenerator: ChannelHandlers = {
715
handleMessage: async ({ msg }) => {
816
const match = TWITTER_REGEX.exec(msg.content);
917
if (!match || msg.author.bot) return; // Ignore bots to prevent loops
10-
msg.suppressEmbeds(true);
11-
const [url] = match;
12-
const alternativeUrl = url.replace(/(x|twitter)\.com/i, "xcancel.com");
13-
await msg.channel.send(
14-
`[Converted to \`xcancel.com\` for members with no \`x\` account](${alternativeUrl})`,
15-
);
18+
const isThreadChannel = THREAD_CHANNELS.includes(msg.channel.id);
19+
if (!isThreadChannel) {
20+
msg.suppressEmbeds(true);
21+
const [url] = match;
22+
const alternativeUrl = url.replace(/(x|twitter)\.com/i, "xcancel.com");
23+
await msg.channel.send(
24+
`[Converted to \`xcancel.com\` for members with no \`x\` account](${alternativeUrl})`,
25+
);
26+
}
1627
},
1728
};
1829

0 commit comments

Comments
 (0)