Skip to content

Commit e8c7842

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

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/components/events/message.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ 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");
10199
const handler = commands[key];
102100

103101
// stop here
@@ -113,6 +111,8 @@ export default async function (msg: Message, type: string): Promise<void> {
113111
if (rateLimitResult.status || rateLimitResult.value.timestamps.length > 5)
114112
return;
115113

114+
msg.body = normalizedBody;
115+
116116
await Promise.allSettled([
117117
quiz(msg),
118118
riddle(msg),
@@ -197,6 +197,7 @@ export default async function (msg: Message, type: string): Promise<void> {
197197
}
198198

199199
log.info("Message", lid, msg.body.slice(0, 150));
200+
msg.body = [key, ...rest].join(" ");
200201

201202
/*
202203
*

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)