mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 23:05:04 +02:00
Last Run Command
This commit is contained in:
@@ -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}`));
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "128.4.0",
|
||||
"version": "128.4.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user