1 |
rakinar2 |
577 |
import { Request, Response } from "express"; |
2 |
|
|
import DiscordClient from "../../client/Client"; |
3 |
|
|
import auth from "../Auth"; |
4 |
|
|
import guildAuth from "../GuildAuth"; |
5 |
|
|
import { Route } from "../Router"; |
6 |
|
|
|
7 |
|
|
export default <Route> { |
8 |
|
|
path: '/guild/:guild', |
9 |
|
|
async get(req: Request, res: Response) { |
10 |
|
|
if (!req.params.guild) |
11 |
|
|
return res.json({msg: 'Guild ID is required', code: 100}); |
12 |
|
|
|
13 |
|
|
try { |
14 |
|
|
const guild = await DiscordClient.client.guilds.fetch(req.params.guild); |
15 |
|
|
await res.json(guild); |
16 |
|
|
} |
17 |
|
|
catch (e) { |
18 |
|
|
console.log(e); |
19 |
|
|
res.json({msg: 'Invalid Guild ID', code: 101}) |
20 |
|
|
} |
21 |
|
|
} |
22 |
|
|
}; |