Skip to content
This repository was archived by the owner on Sep 25, 2024. It is now read-only.

Commit e41b4ea

Browse files
committed
fix error when name has special characters
1 parent a8cd340 commit e41b4ea

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/cmds/setname.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function checkShortCut(nickname, uid, usersData) {
1212
module.exports = {
1313
config: {
1414
name: "setname",
15-
version: "1.4",
15+
version: "1.5",
1616
author: "NTKhang",
1717
countDown: 5,
1818
role: 0,
@@ -71,7 +71,12 @@ module.exports = {
7171
}
7272
else if (mentions.length) {
7373
uids = mentions;
74-
const allName = new RegExp(Object.values(event.mentions).join("|"), "g");
74+
const allName = new RegExp(
75+
Object.values(event.mentions)
76+
.map(name => name.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&")) // fix error when name has special characters
77+
.join("|")
78+
, "g"
79+
);
7580
nickname = nickname.replace(allName, "").trim();
7681
}
7782
else {

0 commit comments

Comments
 (0)