1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// import { BotListener, Emitter } from '#lib';
// import { exec } from 'child_process';
// import { promisify } from 'util';
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
// /* export default */ class ConsoleListener extends BotListener {
// public constructor() {
// super('console', {
// emitter: Emitter.Stdin,
// event: 'line'
// });
// }
// public async exec(line: string) {
// if (line.startsWith('eval ') || line.startsWith('ev ')) {
// /* eslint-disable @typescript-eslint/no-unused-vars */
// const sh = promisify(exec),
// bot = this.client,
// client = this.client,
// config = this.client.config,
// { ActivePunishment, Global, Guild, Level, ModLog, StickyRole } = await import('#lib'),
// {
// ButtonInteraction,
// Collector,
// CommandInteraction,
// Message,
// ActionRow,
// Attachment,
// ButtonComponent,
// MessageCollector,
// InteractionCollector,
// Embed,
// SelectMenuComponent,
// ReactionCollector,
// Collection
// } = await import('discord.js');
// /* eslint-enable @typescript-eslint/no-unused-vars */
// try {
// const depth = /--depth (?<depth>\d+)/.exec(line)?.groups?.depth ?? undefined;
// const hidden = /--hidden/.test(line);
// if (depth) line = line.replace(/--depth \d+/, '');
// if (hidden) line = line.replace(/--hidden/, '');
// const input = line.replace('eval ', '').replace('ev ', '');
// const output = await eval(input);
// console.dir(output, {
// colors: true,
// getters: true,
// maxArrayLength: Infinity,
// maxStringLength: Infinity,
// depth: +(depth ?? 2),
// showHidden: hidden
// });
// } catch (e) {
// console.error(e);
// }
// } else if (line.startsWith('stop')) {
// process.exit(0);
// }
// }
// }
|