File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 1+ import { CHANNELS } from "../constants/channels.js" ;
12import type { ChannelHandlers } from "../types/index.js" ;
23
34export const TWITTER_REGEX =
45 / h t t p s ? : \/ \/ (?: w w w \. ) ? (?: x | t w i t t e r ) \. c o m \/ \w + \/ s t a t u s \/ \d + / i;
56
7+ const THREAD_CHANNELS = [
8+ CHANNELS . events ,
9+ CHANNELS . iBuiltThis ,
10+ CHANNELS . iWroteThis ,
11+ CHANNELS . techReadsAndNews ,
12+ CHANNELS . twitterFeed ,
13+ ] ;
614const 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 | t w i t t e r ) \. c o m / 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 | t w i t t e r ) \. c o m / 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
You can’t perform that action at this time.
0 commit comments