Add application commands publishing

This commit is contained in:
Isaac 2022-08-02 17:32:55 +01:00
parent aa51cd0554
commit 327573a38a
No known key found for this signature in database
GPG Key ID: F4EAABEB0FFCC06A
3 changed files with 41 additions and 0 deletions

View File

@ -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);
}
};

24
src/stdin/commands.js Normal file
View File

@ -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;
}
}
}
};

View File

@ -13,8 +13,10 @@ module.exports = class extends StdinCommand {
try { try {
const res = await eval(toEval); const res = await eval(toEval);
console.log(res); console.log(res);
return true;
} catch (error) { } catch (error) {
this.client.log.error(error); this.client.log.error(error);
return false;
} }
} }
}; };