mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 05:54:33 +02:00
Add last-run file support
This commit is contained in:
@@ -22,7 +22,7 @@ module.exports = class LastRunCommand extends 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.`);
|
||||
if (!command.lastRun) return msg.reply(`The \`${command.name}\` command has never been run.`);
|
||||
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}**.`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class CommandLastRunExportCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'command-last-run-export',
|
||||
aliases: [
|
||||
'cmd-lr-export',
|
||||
'cmd-last-run-export',
|
||||
'command-lr-export',
|
||||
'export-cmd-lr',
|
||||
'export-cmd-last-run',
|
||||
'export-command-lr',
|
||||
'export-command-last-run'
|
||||
],
|
||||
group: 'util',
|
||||
memberName: 'command-last-run-export',
|
||||
description: 'Exports a command last run JSON file.',
|
||||
details: 'Only the bot owner(s) may use this command.',
|
||||
ownerOnly: true,
|
||||
guarded: true
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
const result = this.client.exportLastRun();
|
||||
await msg.direct({ files: [{ attachment: result, name: 'command-last-run.json' }] });
|
||||
return msg.say('📬 Sent `command-last-run.json` to your DMs!');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class CommandLastRunImportCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'command-last-run-import',
|
||||
aliases: [
|
||||
'cmd-lr-import',
|
||||
'cmd-last-run-import',
|
||||
'command-lr-import',
|
||||
'import-cmd-lr',
|
||||
'import-cmd-last-run',
|
||||
'import-command-lr',
|
||||
'import-command-last-run'
|
||||
],
|
||||
group: 'util',
|
||||
memberName: 'command-last-run-import',
|
||||
description: 'Imports a command last run JSON file.',
|
||||
details: 'Only the bot owner(s) may use this command.',
|
||||
ownerOnly: true,
|
||||
guarded: true
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
try {
|
||||
const results = this.client.importLastRun();
|
||||
if (!results) return msg.reply('The JSON file provided is invalid.');
|
||||
return msg.say('Successfully imported command last run.');
|
||||
} catch (err) {
|
||||
return msg.reply(`Could not read \`command-last-run.json\`: \`${err.message}\`.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -24,8 +24,10 @@ module.exports = class ReloadCommand extends Command {
|
||||
|
||||
run(msg, { command }) {
|
||||
this.client.exportCommandLeaderboard();
|
||||
this.client.exportLastRun();
|
||||
command.reload();
|
||||
this.client.importCommandLeaderboard();
|
||||
this.client.importLastRun();
|
||||
return msg.say(`Reloaded the \`${command.name}\` command.`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,6 +50,7 @@ module.exports = class ShutdownCommand extends Command {
|
||||
try {
|
||||
this.uses++;
|
||||
this.client.exportCommandLeaderboard();
|
||||
this.client.exportLastRun();
|
||||
this.client.logger.info('[SHUTDOWN] Manual shutdown engaged.');
|
||||
const text = texts[Math.floor(Math.random() * texts.length)];
|
||||
await msg.say(text);
|
||||
|
||||
Reference in New Issue
Block a user