git subrepo pull core
subrepo: subdir: "core" merged: "7a3eed3" upstream: origin: "git@github.com:benji7425/discord-bot-core.git" branch: "master" commit: "7a3eed3" git-subrepo: version: "0.3.1" origin: "???" commit: "???"master
parent
5fbd288861
commit
e838b60752
@ -1,23 +1,31 @@
|
||||
const Command = require("../command.js");
|
||||
const Util = require("../util.js");
|
||||
|
||||
module.exports = new Command({
|
||||
name: "reset",
|
||||
description: "Reset all data for this Discord server. WARNING: YOU WILL LOSE ALL YOUR SETTINGS!",
|
||||
syntax: "reset",
|
||||
admin: false,
|
||||
admin: true,
|
||||
invoke
|
||||
});
|
||||
|
||||
function invoke({ guildData }) {
|
||||
function invoke({ guildData, client, message }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
/* this is a very hacky way of doing this, but when using .resolve()
|
||||
the guildData object gets saved back to the database straight away,
|
||||
meaning it'd be deleted and instnantly re-created. Using .reject
|
||||
means that .save doesn't get called by the parent. Very hacky but works. */
|
||||
guildData
|
||||
.delete()
|
||||
.then(() => reject("Data for this server successfully deleted"));
|
||||
// .then(() => resolve("Data for this server successfully deleted"))
|
||||
// .catch(() => reject("Error deleting data for this server"));
|
||||
means that .save doesn't get called by the parent. Very hacky but works. */
|
||||
|
||||
Util.ask(client, message.channel, message.member, "Are you sure you want to delete all the data for this server? (yes/no)")
|
||||
.then(response => {
|
||||
if (response.toLowerCase() === "yes")
|
||||
guildData
|
||||
.delete()
|
||||
.then(() => reject("Data for this server successfully deleted"));
|
||||
else
|
||||
reject("Guild data was not deleted");
|
||||
});
|
||||
// .then(() => resolve("Data for this server successfully deleted"))
|
||||
// .catch(() => reject("Error deleting data for this server"));
|
||||
});
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
const Command = require("../command.js");
|
||||
|
||||
module.exports = new Command({
|
||||
name: "stats",
|
||||
description: "Show some stats about the bot",
|
||||
syntax: "stats",
|
||||
admin: false,
|
||||
invoke
|
||||
});
|
||||
|
||||
function invoke({ message, params, guildData, client }) {
|
||||
return Promise.resolve(`
|
||||
**Server count:** ${client.guilds.size}
|
||||
**Cached users:** ${client.users.size}
|
||||
**Uptime:** ${toHHMMSS(client.uptime)}
|
||||
`);
|
||||
}
|
||||
|
||||
function toHHMMSS(ms) {
|
||||
const secsTruncated = Math.trunc(ms / 1000); // don't forget the second param
|
||||
const hrs = Math.floor(secsTruncated / 3600);
|
||||
const mins = Math.floor((secsTruncated - (hrs * 3600)) / 60);
|
||||
const secs = secsTruncated - (hrs * 3600) - (mins * 60);
|
||||
|
||||
let hoursStr = hrs.toString(), minsStr = mins.toString(), secsStr = secs.toString();
|
||||
|
||||
if (hrs < 10) { hoursStr = "0" + hrs; }
|
||||
if (mins < 10) { minsStr = "0" + mins; }
|
||||
if (secs < 10) { secsStr = "0" + secs; }
|
||||
return hoursStr + ":" + minsStr + ":" + secsStr;
|
||||
}
|
Loading…
Reference in New Issue