1 |
|
import { Collection } from "discord.js"; |
2 |
import { dot, object } from "dot-object"; |
import { dot, object } from "dot-object"; |
3 |
import { NextFunction, Response } from "express"; |
import { NextFunction, Response } from "express"; |
4 |
import { body } from "express-validator"; |
import { body } from "express-validator"; |
5 |
import KeyValuePair from "../../types/KeyValuePair"; |
import KeyValuePair from "../../types/KeyValuePair"; |
6 |
|
import BaseCommand from "../../utils/structures/BaseCommand"; |
7 |
import Controller from "../Controller"; |
import Controller from "../Controller"; |
8 |
import RequireAuth from "../middleware/RequireAuth"; |
import RequireAuth from "../middleware/RequireAuth"; |
9 |
import ValidatorError from "../middleware/ValidatorError"; |
import ValidatorError from "../middleware/ValidatorError"; |
12 |
export default class InfoController extends Controller { |
export default class InfoController extends Controller { |
13 |
globalMiddleware(): Function[] { |
globalMiddleware(): Function[] { |
14 |
return [RequireAuth, ValidatorError, (request: Request, response: Response, next: NextFunction) => { |
return [RequireAuth, ValidatorError, (request: Request, response: Response, next: NextFunction) => { |
15 |
|
console.log(`URI: ` + request.path); |
16 |
|
|
17 |
|
if (request.path === "/systeminfo/commands") { |
18 |
|
next(); |
19 |
|
return; |
20 |
|
} |
21 |
|
|
22 |
const { id } = request.params; |
const { id } = request.params; |
23 |
|
|
24 |
if (!request.user?.guilds.includes(id)) { |
if (!request.user?.guilds.includes(id)) { |
51 |
} |
} |
52 |
|
|
53 |
public async indexRoles(request: Request) { |
public async indexRoles(request: Request) { |
54 |
return this.client.guilds.cache.get(request.params.id)?.roles?.cache; |
return this.client.guilds.cache.get(request.params.id)?.roles?.cache.sort((first, second) => second.position - first.position); |
55 |
|
} |
56 |
|
|
57 |
|
public async indexCommands() { |
58 |
|
const commands = new Collection<string, BaseCommand>(); |
59 |
|
|
60 |
|
for (const [name, command] of this.client.commands) { |
61 |
|
if (command.getAliases().includes(name)) { |
62 |
|
console.log(command.getAliases(), "includes", name); |
63 |
|
continue; |
64 |
|
} |
65 |
|
|
66 |
|
if (commands.has(name) || command.ownerOnly) { |
67 |
|
console.log(commands.get(name)?.getName(), name); |
68 |
|
continue; |
69 |
|
} |
70 |
|
|
71 |
|
if (commands.get(name) !== command) |
72 |
|
commands.set(name, command); |
73 |
|
} |
74 |
|
|
75 |
|
return commands.map(command => ({ |
76 |
|
...command, |
77 |
|
permissions: command.permissions.map(perm => perm.toString()), |
78 |
|
})); |
79 |
} |
} |
80 |
|
|
81 |
public async indexGuilds(request: Request) { |
public async indexGuilds(request: Request) { |