/[sudobot]/branches/2.x/src/api/routes/guilds.ts
ViewVC logotype

Contents of /branches/2.x/src/api/routes/guilds.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1099 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 import { Collection, Guild, OAuth2Guild } from "discord.js";
2 import { Request, Response } from "express";
3 import DiscordClient from "../../client/Client";
4 import auth from "../Auth";
5 import guildAuth from "../GuildAuth";
6 import { Route } from "../Router";
7
8 export default <Route> {
9 path: '/guilds',
10 async post(req: Request, res: Response) {
11 let guilds = [];
12
13 if (!req.body.guilds || !(req.body.guilds instanceof Array)) {
14 res.json({});
15
16 return;
17 }
18
19 for await (const id of req.body.guilds) {
20 console.log(id);
21
22 if (!DiscordClient.client.config.props[id]) {
23 continue;
24 }
25
26 guilds.push(await DiscordClient.client.guilds.fetch(id));
27 }
28
29 console.log(guilds);
30
31 await res.json({
32 guilds: guilds.map(({ id, name, ownerId, iconURL }: any) => {
33 return {
34 id,
35 name,
36 ownerId,
37 iconURL
38 }
39 })
40 });
41 }
42 };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26