|
1 | 1 | import express, { type NextFunction, type Request, type Response } from "express"; |
2 | 2 | import cors from "cors"; |
3 | 3 | import path from "path"; |
4 | | -import { getBotInfo, getGuild, getUser, getUsers, initTables, pool, updateGuild, enableUpdates, disableUpdates, setCooldown, setUpdatesChannel, setXP, setLevel } from "./db"; |
| 4 | +import { getBotInfo, getGuild, getUser, getUsers, initTables, pool, updateGuild, enableUpdates, disableUpdates, setCooldown, setUpdatesChannel, setXP, setLevel, removeGuild } from "./db"; |
5 | 5 |
|
6 | 6 | const app = express(); |
7 | 7 | const PORT = 18103; |
@@ -43,6 +43,17 @@ app.post("/post/:guild", authMiddleware, async (req, res) => { |
43 | 43 | } |
44 | 44 | }); |
45 | 45 |
|
| 46 | +app.post('/post/:guild/remove', authMiddleware, async (req, res) => { |
| 47 | + const { guild } = req.params; |
| 48 | + const [err, results] = await removeGuild(guild); |
| 49 | + |
| 50 | + if (err) { |
| 51 | + res.status(500).json({ message: "Internal server error" }); |
| 52 | + } else { |
| 53 | + res.status(200).json(results); |
| 54 | + } |
| 55 | +}) |
| 56 | + |
46 | 57 | app.post("/post/:guild/:user", authMiddleware, async (req, res) => { |
47 | 58 | const { guild, user } = req.params; |
48 | 59 | const { name, pfp, xp, nickname } = req.body; |
@@ -339,7 +350,7 @@ app.get("/leaderboard/:guild", async (req, res) => { |
339 | 350 | const [usersErr, usersData] = await getUsers(guild); |
340 | 351 |
|
341 | 352 | if (!guildData) { |
342 | | - return res.status(404).render("error", { error: { status: 404, message: "The guild does not exist" } }); |
| 353 | + 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" } }); |
343 | 354 | } |
344 | 355 |
|
345 | 356 | if (guildErr) { |
|
0 commit comments