Skip to content

Commit 71e86c8

Browse files
committed
feat: bug fixes and improvements
1 parent 3d3a5c3 commit 71e86c8

7 files changed

Lines changed: 22 additions & 53 deletions

File tree

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ dist
55
.temp
66
*.log
77
*.env
8-
9-
/src/generated/prisma

prisma/schema.prisma

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
generator client {
88
provider = "prisma-client-js"
9-
output = "../src/generated/prisma"
109
}
1110

1211
datasource db {

src/commands/quiz.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ export default async function (msg: Message) {
1818
const id = Math.floor(Math.random() * quiz.length);
1919
const response = quiz[id];
2020

21-
if (response.length === 0)
22-
return await msg.reply("I don't have any quiz questions right now...");
23-
2421
let text = `
2522
\`${response.question}\`
2623
`;

src/commands/wyr.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Message } from "../../types/message"
1+
import { Message } from "../../types/message";
22
import { wyr } from "../components/utils/data";
33

44
export const info = {
@@ -14,8 +14,6 @@ export default async function (msg: Message) {
1414
if (!/^wyr$/i.test(msg.body)) return;
1515

1616
const response = wyr[Math.floor(Math.random() * wyr.length)];
17-
if (response.length === 0)
18-
return await msg.reply("I don't have any jokes right now...");
1917
const text = `
2018
\`Would you rather?\`
2119

src/components/prisma.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { PrismaClient } from "../generated/prisma";
1+
import { PrismaClient } from "@prisma/client";
22

33
const nodeEnv = process.env.NODE_ENV || "development";
4+
45
const globalForPrisma = globalThis as unknown as {
56
prisma: PrismaClient | undefined;
67
};

src/components/utils/data.ts

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,21 @@
1-
import fs from "fs";
2-
import log from "./log";
3-
import path from "path";
4-
import LoadingBar from "./loadingBar";
1+
import greetings from "../../data/greetings.json";
2+
import ball from "../../data/8ball.json";
3+
import cat from "../../data/cat.json";
4+
import dyk from "../../data/dyk.json";
5+
import joke from "../../data/joke.json";
6+
import quiz from "../../data/quiz.json";
7+
import wyr from "../../data/wyr.json";
8+
import errors from "../../data/errors.json";
59

6-
function safeReadJSON(filePath: string) {
7-
try {
8-
return JSON.parse(
9-
fs.readFileSync(path.resolve(__dirname, filePath), "utf-8")
10-
);
11-
} catch (error) {
12-
log.error("Data", `Failed to read JSON from ${filePath}`, error);
13-
return [];
14-
}
15-
}
16-
17-
const files: Record<string, string> = {
18-
greetings: "../../data/greetings.json",
19-
ball: "../../data/8ball.json",
20-
cat: "../../data/cat.json",
21-
dyk: "../../data/dyk.json",
22-
joke: "../../data/joke.json",
23-
quiz: "../../data/quiz.json",
24-
wyr: "../../data/wyr.json",
25-
errors: "../../data/errors.json",
10+
const files = {
11+
greetings,
12+
ball,
13+
cat,
14+
dyk,
15+
joke,
16+
quiz,
17+
wyr,
18+
errors,
2619
};
2720

28-
const progressBar = LoadingBar(
29-
"Loading Data | {bar} | {value}/{total} {filename}"
30-
);
31-
32-
progressBar.start(Object.keys(files).length, 0, {
33-
filename: "",
34-
});
35-
36-
const data: Record<string, any> = {};
37-
for (const [key, filePath] of Object.entries(files)) {
38-
data[key] = safeReadJSON(filePath);
39-
progressBar.increment(1, { filename: path.basename(filePath) });
40-
}
41-
42-
progressBar.stop();
43-
44-
const { greetings, ball, cat, dyk, joke, quiz, wyr, errors } = data;
4521
export { greetings, ball, cat, dyk, joke, quiz, wyr, errors };

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"rootDir": "./src",
1212
"strict": true,
1313
"moduleResolution": "node",
14-
"skipLibCheck": true,
15-
"typeRoots": ["./node_modules/@types", "./types"]
14+
"skipLibCheck": true,
15+
"typeRoots": ["./node_modules/@types", "./types"],
1616
},
1717
"include": ["src"]
1818
}

0 commit comments

Comments
 (0)