🎨 Convert id bigint to string
This commit is contained in:
@@ -11,7 +11,7 @@ import { getPublicUser } from "../../../util/User";
|
||||
const router: Router = Router();
|
||||
|
||||
router.get("/", async (req: Request, res: Response) => {
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const guild_id = req.params.id;
|
||||
|
||||
const guild = await GuildModel.findOne({ id: guild_id }).exec();
|
||||
if (!guild) throw new HTTPError("Guild not found", 404);
|
||||
@@ -21,8 +21,8 @@ router.get("/", async (req: Request, res: Response) => {
|
||||
});
|
||||
|
||||
router.get("/:user", async (req: Request, res: Response) => {
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const user_id = BigInt(req.params.ban);
|
||||
const guild_id = req.params.id;
|
||||
const user_id = req.params.ban;
|
||||
|
||||
var ban = await BanModel.findOne({ guild_id: guild_id, user_id: user_id }).exec();
|
||||
if (!ban) throw new HTTPError("Ban not found", 404);
|
||||
@@ -30,8 +30,8 @@ router.get("/:user", async (req: Request, res: Response) => {
|
||||
});
|
||||
|
||||
router.post("/:user_id", check(BanCreateSchema), async (req: Request, res: Response) => {
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const banned_user_id = BigInt(req.params.user_id);
|
||||
const guild_id = req.params.id;
|
||||
const banned_user_id = req.params.user_id;
|
||||
|
||||
const banned_user = await getPublicUser(banned_user_id);
|
||||
const perms = await getPermission(req.user_id, guild_id);
|
||||
@@ -61,8 +61,8 @@ router.post("/:user_id", check(BanCreateSchema), async (req: Request, res: Respo
|
||||
});
|
||||
|
||||
router.delete("/:user_id", async (req: Request, res: Response) => {
|
||||
var guild_id = BigInt(req.params.id);
|
||||
var banned_user_id = BigInt(req.params.user_id);
|
||||
var guild_id = req.params.id;
|
||||
var banned_user_id = req.params.user_id;
|
||||
|
||||
const banned_user = await getPublicUser(banned_user_id);
|
||||
const guild = await GuildModel.findOne({ id: guild_id }, { id: true }).exec();
|
||||
|
||||
@@ -6,14 +6,14 @@ import { check } from "../../../util/instanceOf";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const guild_id = (req.params.id);
|
||||
const channels = await ChannelModel.find({ guild_id }).lean().exec();
|
||||
|
||||
res.json(channels);
|
||||
});
|
||||
|
||||
router.post("/", check(ChannelModifySchema), async (req, res) => {
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const guild_id = (req.params.id);
|
||||
const body = req.body as ChannelModifySchema;
|
||||
if (!body.permission_overwrites) body.permission_overwrites = [];
|
||||
if (!body.topic) body.topic = "";
|
||||
|
||||
@@ -19,7 +19,7 @@ import { check } from "../../../util/instanceOf";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", async (req: Request, res: Response) => {
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const guild_id = req.params.id;
|
||||
|
||||
const guild = await GuildModel.findOne({ id: guild_id }).exec();
|
||||
if (!guild) throw new HTTPError("Guild does not exist", 404);
|
||||
@@ -32,7 +32,7 @@ router.get("/", async (req: Request, res: Response) => {
|
||||
|
||||
router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response) => {
|
||||
const body = req.body as GuildUpdateSchema;
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const guild_id = req.params.id;
|
||||
|
||||
const guild = await GuildModel.findOne({ id: guild_id }).exec();
|
||||
if (!guild) throw new HTTPError("This guild does not exist", 404);
|
||||
@@ -45,7 +45,7 @@ router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response)
|
||||
});
|
||||
|
||||
router.delete("/", async (req: Request, res: Response) => {
|
||||
var guild_id = BigInt(req.params.id);
|
||||
var guild_id = req.params.id;
|
||||
|
||||
const guild = await GuildModel.findOne({ id: guild_id }, "owner_id").exec();
|
||||
if (!guild) throw new HTTPError("This guild does not exist", 404);
|
||||
|
||||
@@ -10,12 +10,12 @@ const router = Router();
|
||||
// TODO: not allowed for user -> only allowed for bots with privileged intents
|
||||
// TODO: send over websocket
|
||||
router.get("/", async (req: Request, res: Response) => {
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const guild_id = req.params.id;
|
||||
const guild = await GuildModel.findOne({ id: guild_id }).exec();
|
||||
if (!guild) throw new HTTPError("Guild not found", 404);
|
||||
|
||||
try {
|
||||
instanceOf({ $limit: new Length(Number, 1, 1000), $after: BigInt }, req.query, {
|
||||
instanceOf({ $limit: new Length(Number, 1, 1000), $after: String }, req.query, {
|
||||
path: "query",
|
||||
req,
|
||||
ref: { obj: null, key: "" },
|
||||
@@ -26,7 +26,7 @@ router.get("/", async (req: Request, res: Response) => {
|
||||
|
||||
// @ts-ignore
|
||||
if (!req.query.limit) req.query.limit = 1;
|
||||
const { limit, after } = (<unknown>req.query) as { limit: number; after: bigint };
|
||||
const { limit, after } = (<unknown>req.query) as { limit: number; after: string };
|
||||
const query = after ? { id: { $gt: after } } : {};
|
||||
|
||||
var members = await MemberModel.find({ guild_id, ...query }, PublicMemberProjection)
|
||||
@@ -39,8 +39,8 @@ router.get("/", async (req: Request, res: Response) => {
|
||||
});
|
||||
|
||||
router.get("/:member", async (req: Request, res: Response) => {
|
||||
const guild_id = BigInt(req.params.id);
|
||||
const user_id = BigInt(req.params.member);
|
||||
const guild_id = req.params.id;
|
||||
const user_id = req.params.member;
|
||||
|
||||
const member = await MemberModel.findOne({ id: user_id, guild_id }).populate({ path: "user", select: PublicUserProjection }).exec();
|
||||
if (!member) throw new HTTPError("Member not found", 404);
|
||||
|
||||
Reference in New Issue
Block a user