Skip to content

Commit 557e177

Browse files
committed
fix: only the key is lowercase
1 parent 7a90f07 commit 557e177

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/components/events/message.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,24 @@ export default async function (msg: Message, type: string): Promise<void> {
9696
const normalizedBody = cleanedBody.replace(/\s+/g, " ").trim();
9797
const [command, ...rest] = normalizedBody.split(" ");
9898
const key = command.toLocaleLowerCase("en");
99-
100-
msg.body = [command, ...rest].join(" ").toLocaleLowerCase("en");
99+
const newMessageBody = [key, ...rest].join(" ");
101100
const handler = commands[key];
102101

103102
// stop here
104103
// the command matched to the usage but the input aint
105104
if (
106105
handler &&
107106
handler.usage === handler.command &&
108-
handler.command !== msg.body
107+
handler.command !== newMessageBody
109108
)
110109
return;
111110

112111
if (!handler) {
113112
if (rateLimitResult.status || rateLimitResult.value.timestamps.length > 5)
114113
return;
115114

115+
msg.body = normalizedBody;
116+
116117
await Promise.allSettled([
117118
quiz(msg),
118119
riddle(msg),
@@ -197,6 +198,7 @@ export default async function (msg: Message, type: string): Promise<void> {
197198
}
198199

199200
log.info("Message", lid, msg.body.slice(0, 150));
201+
msg.body = newMessageBody;
200202

201203
/*
202204
*

src/components/utils/quiz.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default async function (msg: Message): Promise<void> {
1717

1818
const quizAttempt = JSON.parse(result);
1919
const question = quiz[parseInt(quizAttempt.quiz_id)];
20-
const userInput = msg.body.trim().toLowerCase().replace(/!/g, "");
20+
const userInput = msg.body.trim().toLowerCase();
2121
const answer = question.answer.replace(/\s+/g, "").toLowerCase();
2222
// Find the index of the correct answer in choices
2323
const answerIndex = question.choices

src/components/utils/riddle.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default async function (msg: Message): Promise<void> {
2020
const userInput = msg.body
2121
.trim()
2222
.toLowerCase()
23-
.replace(/!/g, "")
2423
.split(/\s+/);
2524
const answer = riddle.answer.toLowerCase();
2625

0 commit comments

Comments
 (0)