|
import { Request } from "express"; |
|
1 |
import Controller from "../Controller"; |
import Controller from "../Controller"; |
2 |
|
import RequireAuth from "../middleware/RequireAuth"; |
3 |
|
import Request from "../Request"; |
4 |
|
|
5 |
export default class ConfigController extends Controller { |
export default class ConfigController extends Controller { |
6 |
|
globalMiddleware(): Function[] { |
7 |
|
return [RequireAuth]; |
8 |
|
} |
9 |
|
|
10 |
public async index(request: Request) { |
public async index(request: Request) { |
11 |
|
const { id } = request.params; |
12 |
|
|
13 |
|
if (!request.user?.guilds.includes(id)) { |
14 |
|
return this.response({ error: "You don't have permission to access configuration of this guild." }, 403); |
15 |
|
} |
16 |
|
|
17 |
|
if (id === "global" || !this.client.config.props[id]) { |
18 |
|
return this.response({ error: "No configuration found for the given guild ID" }, 404); |
19 |
|
} |
20 |
|
|
21 |
|
return this.client.config.props[id]; |
22 |
} |
} |
23 |
|
|
24 |
public async update(request: Request) { |
public async update(request: Request) { |