From 327573a38a0793a16eba6dcc9c241065f005dfe0 Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 2 Aug 2022 17:32:55 +0100 Subject: [PATCH] Add application commands publishing --- src/listeners/stdin/unknown.js | 15 +++++++++++++++ src/stdin/commands.js | 24 ++++++++++++++++++++++++ src/stdin/eval.js | 2 ++ 3 files changed, 41 insertions(+) create mode 100644 src/listeners/stdin/unknown.js create mode 100644 src/stdin/commands.js diff --git a/src/listeners/stdin/unknown.js b/src/listeners/stdin/unknown.js new file mode 100644 index 0000000..d68e27a --- /dev/null +++ b/src/listeners/stdin/unknown.js @@ -0,0 +1,15 @@ +const { Listener } = require('@eartharoid/dbf'); + +module.exports = class extends Listener { + constructor(client, options) { + super(client, { + ...options, + emitter: client.stdin, + event: 'unknown', + }); + } + + run(commandName) { + console.log('Unknown command:', commandName); + } +}; diff --git a/src/stdin/commands.js b/src/stdin/commands.js new file mode 100644 index 0000000..6b1242b --- /dev/null +++ b/src/stdin/commands.js @@ -0,0 +1,24 @@ +const { StdinCommand } = require('@eartharoid/dbf'); + +module.exports = class Commands extends StdinCommand { + constructor(client, options) { + super(client, { + ...options, + id: 'commands', + }); + } + + async run(args) { + switch (args[0]) { + case 'publish': { + this.client.commands.publish() + .then(commands => { + if (!commands) return console.log('None published'); + console.log('Published %d commands', commands.size); + }) + .catch(console.error); + break; + } + } + } +}; \ No newline at end of file diff --git a/src/stdin/eval.js b/src/stdin/eval.js index c081510..e9787b6 100644 --- a/src/stdin/eval.js +++ b/src/stdin/eval.js @@ -13,8 +13,10 @@ module.exports = class extends StdinCommand { try { const res = await eval(toEval); console.log(res); + return true; } catch (error) { this.client.log.error(error); + return false; } } }; \ No newline at end of file