File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,13 @@ const socialNetworksUrlRegex = new RegExp(
4
4
const punctuationRegex = / [ . , ! ? ] / g;
5
5
const markdownRegex = / ( \* \* | _ _ | \* | _ | ` | ~ ) ( .* ?) \1/ g;
6
6
const emojiRegex = / < a ? : .+ ?: \d { 10 , 30 } > | \p{ Extended_Pictographic} / gu;
7
+ const nonASCIIRegex = / [ \u{007F} - \u{FFFF} ] / gu;
7
8
8
9
export const isASocialNetworkUrl = ( url : string ) : boolean => {
9
10
return socialNetworksUrlRegex . test ( url ) ;
10
11
} ;
11
12
12
13
export const removePunctuation = ( text : string ) => text . replaceAll ( punctuationRegex , '' ) ;
13
14
export const removeEmoji = ( text : string ) => text . replaceAll ( emojiRegex , '' ) ;
15
+ export const removeNonASCII = ( text : string ) => text . replaceAll ( nonASCIIRegex , '' ) ;
14
16
export const removeMarkdown = ( text : string ) => text . replaceAll ( markdownRegex , '$2' ) ;
Original file line number Diff line number Diff line change @@ -7,13 +7,18 @@ import {
7
7
} from 'discord.js' ;
8
8
9
9
import { cache } from '../../core/cache' ;
10
- import { removeEmoji , removeMarkdown , removePunctuation } from '../../helpers/regex.helper' ;
10
+ import {
11
+ removeEmoji ,
12
+ removeMarkdown ,
13
+ removeNonASCII ,
14
+ removePunctuation ,
15
+ } from '../../helpers/regex.helper' ;
11
16
12
17
const ONE_MINUTE = 1 * 60 * 1000 ;
13
18
14
19
const quoiDetectorRegex = / \b q u o i \s * $ / i;
15
20
const endWithQuoi = ( text : string ) =>
16
- quoiDetectorRegex . test ( removeEmoji ( removePunctuation ( removeMarkdown ( text ) ) ) ) ;
21
+ quoiDetectorRegex . test ( removeNonASCII ( removeEmoji ( removePunctuation ( removeMarkdown ( text ) ) ) ) ) ;
17
22
18
23
const reactWith = async ( message : Message , reactions : string [ ] ) => {
19
24
for ( const reaction of reactions ) {
You can’t perform that action at this time.
0 commit comments