Last Run Command

This commit is contained in:
Dragon Fire
2021-02-01 21:33:52 -05:00
parent 563f3109f5
commit 9d4b525333
4 changed files with 33 additions and 1 deletions
+2
View File
@@ -188,6 +188,8 @@ client.on('warn', warn => client.logger.warn(warn));
client.on('commandRun', command => {
if (command.uses === undefined) return;
command.uses++;
if (command.lastRun === undefined) return;
command.lastRun = new Date();
});
client.on('commandError', (command, err) => client.logger.error(`[COMMAND:${command.name}]\n${err.stack}`));
+29
View File
@@ -0,0 +1,29 @@
const Command = require('../../structures/Command');
const moment = require('moment');
module.exports = class LastRunCommand extends Command {
constructor(client) {
super(client, {
name: 'last-run',
aliases: ['command-last-run', 'cmd-last-run', 'cmd-run', 'command-run'],
group: 'util-public',
memberName: 'last-run',
description: 'Responds with a command\'s most recent run date.',
guarded: true,
args: [
{
key: 'command',
prompt: 'Which command would you like to view the last run date of?',
type: 'command'
}
]
});
}
run(msg, { command }) {
if (command.lastRun === undefined) return msg.reply('That command\'s usage stats aren\'t being tracked.');
if (!command.lastRun) return msg.reply(`The \`${command.name}\` command has not been run since last reboot.`);
const displayTime = moment.utc(command.lastRun).format('MM/DD/YYYY h:mm A');
return msg.say(`The \`${command.name}\` command was last run on **${displayTime}**.`);
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "128.4.0",
"version": "128.4.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
+1
View File
@@ -8,6 +8,7 @@ module.exports = class XiaoCommand extends Command {
this.argsSingleQuotes = info.argsSingleQuotes || false;
this.throttling = info.unknown ? null : info.throttling || { usages: 1, duration: 2 };
this.uses = 0;
this.lastRun = null;
this.credit = info.credit || [];
this.credit.push({
name: 'Dragon Fire',