aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/other
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-19 16:43:37 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-19 16:43:37 -0400
commitea64ebfff9aae32deb036643422d3427959dcd24 (patch)
tree5ab83558642bad282515837424637070f547a05e /src/listeners/other
parentd055e0dbb86ef7fd4ee96a1531b51181e825fb4b (diff)
downloadtanzanite-ea64ebfff9aae32deb036643422d3427959dcd24.tar.gz
tanzanite-ea64ebfff9aae32deb036643422d3427959dcd24.tar.bz2
tanzanite-ea64ebfff9aae32deb036643422d3427959dcd24.zip
feat(*): A bunch of stuff
- Remade logging - updated dependencies - started adding custom crap to the command handler - added emojis to stuff - can't remeber other stuff Note: this is currently broken BREAKING CHANGE:
Diffstat (limited to 'src/listeners/other')
-rw-r--r--src/listeners/other/consoleListener.ts50
-rw-r--r--src/listeners/other/promiseRejection.ts23
2 files changed, 73 insertions, 0 deletions
diff --git a/src/listeners/other/consoleListener.ts b/src/listeners/other/consoleListener.ts
new file mode 100644
index 0000000..50c0cf3
--- /dev/null
+++ b/src/listeners/other/consoleListener.ts
@@ -0,0 +1,50 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
+import { BushListener } from '../../lib/extensions/BushListener';
+
+export default class ConsoleListener extends BushListener {
+ public constructor() {
+ super('console', {
+ emitter: 'stdin',
+ event: 'line'
+ });
+ }
+
+ public async exec(line: string): Promise<void> {
+ const bot = this.client;
+ if (line.startsWith('eval ')) {
+ try {
+ const input = line.replace('eval ', '');
+ let output = eval(input);
+ output = await output;
+ console.log(output);
+ } catch (e) {
+ console.error(e);
+ }
+ }
+ if (line.startsWith('ev ')) {
+ try {
+ const input = line.replace('ev ', '');
+ let output = eval(input);
+ output = await output;
+ console.log(output);
+ } catch (e) {
+ console.error(e);
+ }
+ } /* else if (line.startsWith('reload')) {
+ exec('npx tsc', (error) => {
+ if (error) {
+ return this.client.console.error('Reload', `Error recompiling, \`${error.message}\``);
+ }
+ try {
+ this.client.commandHandler.reloadAll();
+ this.client.listenerHandler.reloadAll();
+ } catch (e) {
+ return this.client.console.error('Reload', e);
+ }
+ this.client.console.success('Reload', 'Reloaded successfully.');
+ });
+ } else if (line.startsWith('stop') || line.startsWith('exit')) {
+ process.exit();
+ } */
+ }
+}
diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts
new file mode 100644
index 0000000..2d7e316
--- /dev/null
+++ b/src/listeners/other/promiseRejection.ts
@@ -0,0 +1,23 @@
+import { BushListener } from '../../lib/extensions/BushListener';
+
+export default class PromiseRejectionListener extends BushListener {
+ constructor() {
+ super('promiseRejection', {
+ emitter: 'process',
+ event: 'unhandledRejection'
+ });
+ }
+
+ public async exec(error: Error): Promise<void> {
+ this.client.console.error('PromiseRejection', 'An unhanded promise rejection occurred:\n' + error.stack, false);
+ await this.client.console.channelError({
+ embeds: [
+ {
+ title: 'Unhandled promise rejection',
+ fields: [{ name: 'error', value: await this.client.util.codeblock(error.stack, 1024, 'js') }],
+ color: this.client.util.colors.error
+ }
+ ]
+ });
+ }
+}