mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
[Route] PUT /guilds/:id/members
Not tested
This commit is contained in:
parent
b2665a0a54
commit
b8ca880247
12309
package-lock.json
generated
12309
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,10 @@
|
|||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import { GuildModel, MemberModel, toObject } from "@fosscord/server-util";
|
import { GuildModel, MemberModel, UserModel, toObject, GuildMemberAddEvent } from "@fosscord/server-util";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
import { instanceOf, Length } from "../../../util/instanceOf";
|
import { instanceOf, Length } from "../../../util/instanceOf";
|
||||||
import { PublicMemberProjection } from "../../../util/Member";
|
import { PublicMemberProjection, addMember } from "../../../util/Member";
|
||||||
import { PublicUserProjection } from "../../../util/User";
|
import { emitEvent } from "../../../util/Event";
|
||||||
|
import { getPublicUser } from "../../../util/User";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
@ -47,6 +48,17 @@ router.get("/:member", async (req: Request, res: Response) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.put("/:member", async (req: Request, res: Response) => {
|
router.put("/:member", async (req: Request, res: Response) => {
|
||||||
|
const { guild_id } = req.params;
|
||||||
|
const guild = await GuildModel.findOne({ id: guild_id }).exec();
|
||||||
|
if (!guild) throw new HTTPError("Guild not found", 404);
|
||||||
|
|
||||||
|
const user_id = req.params.member;
|
||||||
|
|
||||||
|
const user = await UserModel.findOne({ id: user_id }).exec();
|
||||||
|
if (!user) throw new HTTPError("User not found", 404);
|
||||||
|
|
||||||
|
await addMember(user_id, guild_id);
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/guild#add-guild-member
|
// https://discord.com/developers/docs/resources/guild#add-guild-member
|
||||||
});
|
});
|
||||||
|
|
||||||
|
13
src/schema/Member.ts
Normal file
13
src/schema/Member.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export const MemberCreateSchema = {
|
||||||
|
id: String,
|
||||||
|
nick: String,
|
||||||
|
guild_id: String,
|
||||||
|
joined_at: Date,
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface MemberCreateSchema {
|
||||||
|
id: string;
|
||||||
|
nick: string;
|
||||||
|
guild_id: string;
|
||||||
|
joined_at: Date;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user