|
1 | 1 | import express, { type NextFunction, type Request, type Response } from "express";
|
2 | 2 | import cors from "cors";
|
3 |
| -import path from "path"; |
4 | 3 | import { getBotInfo, getGuild, getUser, getUsers, initTables, pool, updateGuild, enableUpdates, disableUpdates, setCooldown, setUpdatesChannel, setXP, setLevel, removeGuild, removeUser } from "./db";
|
5 | 4 |
|
6 | 5 | const app = express();
|
7 | 6 | const PORT = 18103;
|
8 | 7 |
|
9 | 8 | app.use(cors());
|
10 | 9 | app.use(express.json());
|
11 |
| -app.use(express.static(path.join(__dirname, "public"))); |
12 |
| -app.set("view engine", "ejs"); |
13 |
| -app.set("views", path.join(__dirname, "views")); |
14 | 10 |
|
15 | 11 | app.disable("x-powered-by");
|
16 | 12 |
|
@@ -460,44 +456,12 @@ app.post("/admin/:action/:guild/:target", authMiddleware, async (req, res) => {
|
460 | 456 | }
|
461 | 457 | });
|
462 | 458 |
|
463 |
| -app.get("/leaderboard/:guild", async (req, res) => { |
464 |
| - const { guild } = req.params; |
465 |
| - const [guildErr, guildData] = await getGuild(guild); |
466 |
| - const [usersErr, usersData] = await getUsers(guild); |
467 |
| - |
468 |
| - if (!guildData) { |
469 |
| - return res.status(404).render("error", { error: { status: 404, message: "The guild does not exist. If Chatr is no longer in this server, the data for this guild has been locked from public access" } }); |
470 |
| - } |
471 |
| - |
472 |
| - if (guildErr) { |
473 |
| - console.error("Error fetching guild:", guildErr); |
474 |
| - res.status(500).render("error", { error: { status: 500, message: "Internal server error whilst trying to fetch guild info. Or the guild does not exist" } }); |
475 |
| - } else if (usersErr) { |
476 |
| - console.error("Error fetching users:", usersErr); |
477 |
| - res.status(500).render("error", { error: { status: 500, message: "Internal server error whilst trying to fetch user info" } }); |
478 |
| - } |
479 |
| - |
480 |
| - res.render("leaderboard", { |
481 |
| - guild: guildData, |
482 |
| - leaderboard: usersData, |
483 |
| - }); |
484 |
| -}); |
485 |
| - |
486 |
| -app.get("/", async (_req, res) => { |
487 |
| - const [err, botInfo] = await getBotInfo(); |
488 |
| - if (err) { |
489 |
| - console.error("Error fetching bot info:", err); |
490 |
| - res.status(500).render("error", { error: { status: 500, message: "Internal server error whilst trying to fetch bot info" } }); |
491 |
| - } |
492 |
| - res.render("index", { botInfo }); |
493 |
| -}); |
494 |
| - |
495 | 459 | app.get("/invite", (_req, res) => res.status(308).redirect("https://discord.com/oauth2/authorize?client_id=1245807579624378601&permissions=1099780115520&integration_type=0&scope=bot+applications.commands"));
|
496 | 460 |
|
497 | 461 | app.get('/support', (_req, res) => res.status(308).redirect('https://discord.gg/fpJVTkVngm'));
|
498 | 462 |
|
499 | 463 | app.use((_req, res) => {
|
500 |
| - res.status(404).render("error", { error: { status: 404, message: "Page doesn't exist" } }); |
| 464 | + res.status(404).json({ message: "Not found" }); |
501 | 465 | });
|
502 | 466 |
|
503 | 467 | app.listen(PORT, () => {
|
|
0 commit comments