Skip to content

Commit 310061c

Browse files
committed
fix: update command regex to match exact phrases for improved command recognition
1 parent 085b8fc commit 310061c

15 files changed

Lines changed: 35 additions & 12 deletions

File tree

src/commands/cat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const info = {
1111
};
1212

1313
export default async function (msg: Message) {
14-
if (!/^cat\b/i.test(msg.body)) return;
14+
if (!/^cat$/i.test(msg.body)) return;
1515

1616
const response = cat[Math.floor(Math.random() * cat.length)];
1717
if (response.length === 0) return await msg.reply("Cat is silent...");

src/commands/dyk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const info = {
1111
};
1212

1313
export default async function (msg: Message) {
14-
if (!/^dyk\b/i.test(msg.body)) return;
14+
if (!/^dyk$/i.test(msg.body)) return;
1515

1616
const response = dyk[Math.floor(Math.random() * dyk.length)];
1717
if (response.length === 0) return await msg.reply("I dont know...");

src/commands/fork.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const info = {
1010
};
1111

1212
export default async function (msg: Message) {
13-
if (!/^fork\b/i.test(msg.body)) return;
13+
if (!/^fork$/i.test(msg.body)) return;
1414

1515
await msg.reply(
1616
"Fork this bot at https://github.com/mrepol742/project-canis or contribute to the project by submitting issues or pull requests."

src/commands/joke.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const info = {
1111
};
1212

1313
export default async function (msg: Message) {
14-
if (!/^joke\b/i.test(msg.body)) return;
14+
if (!/^joke$/i.test(msg.body)) return;
1515

1616
const response = joke[Math.floor(Math.random() * joke.length)];
1717
if (response.length === 0) return await msg.reply("I don't have any jokes right now...");

src/commands/logout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const info = {
1212
};
1313

1414
export default async function (msg: Message) {
15-
if (!/^logout\b/i.test(msg.body)) return;
15+
if (!/^logout$/i.test(msg.body)) return;
1616

1717
try {
1818
await client.logout();

src/commands/pickupline.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export const info = {
1515
};
1616

1717
export default async function (msg: Message) {
18+
if (!/^pickupline$/i.test(msg.body)) return;
19+
1820
await axios
1921
.get(`https://api.popcat.xyz/pickuplines`)
2022
.then(async (response) => {

src/commands/ping.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const info = {
1111
};
1212

1313
export default function (msg: Message) {
14-
if (!/^ping\b/i.test(msg.body)) return;
14+
if (!/^ping$/i.test(msg.body)) return;
15+
1516
msg.reply("pong");
1617
}

src/commands/quiz.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const info = {
1111
};
1212

1313
export default async function (msg: Message) {
14-
if (!/^quiz\b/i.test(msg.body)) return;
14+
if (!/^quiz$/i.test(msg.body)) return;
1515

1616
const response = quiz[Math.floor(Math.random() * quiz.length)];
1717
if (response.length === 0)

src/commands/randomcolor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export const info = {
1414
};
1515

1616
export default async function (msg: Message) {
17+
if (!/^randomcolor$/i.test(msg.body)) return;
18+
1719
await axios
1820
.get(`https://api.popcat.xyz/randomcolor`)
1921
.then(async (response) => {

src/commands/restart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const info = {
1212
};
1313

1414
export default async function (msg: Message) {
15-
if (!/^restart\b/i.test(msg.body)) return;
15+
if (!/^restart$/i.test(msg.body)) return;
1616
await msg.react("🔄");
1717

1818
const tempDir = "./.temp";

0 commit comments

Comments
 (0)