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:   "???"
This commit is contained in:
benji7425 2018-02-11 00:16:58 +00:00
parent 70f078c4b2
commit 792b62fc73
6 changed files with 62 additions and 16 deletions

View File

@ -6,7 +6,7 @@
[subrepo] [subrepo]
remote = git@github.com:benji7425/discord-bot-core.git remote = git@github.com:benji7425/discord-bot-core.git
branch = master branch = master
commit = 1f14a507e709c12bb648929b16e0f45366d12d46 commit = 7a3eed3eff576ed51cfdfbbad18df07d4fcf52a7
parent = 4b5d20902e536495f45cb602dd2151012a5e4aa8 parent = 09cf5233db442fa0af452e84e90289619532418a
method = merge method = merge
cmdver = 0.3.1 cmdver = 0.3.1

View File

@ -1,23 +1,31 @@
const Command = require("../command.js"); const Command = require("../command.js");
const Util = require("../util.js");
module.exports = new Command({ module.exports = new Command({
name: "reset", name: "reset",
description: "Reset all data for this Discord server. WARNING: YOU WILL LOSE ALL YOUR SETTINGS!", description: "Reset all data for this Discord server. WARNING: YOU WILL LOSE ALL YOUR SETTINGS!",
syntax: "reset", syntax: "reset",
admin: false, admin: true,
invoke invoke
}); });
function invoke({ guildData }) { function invoke({ guildData, client, message }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
/* this is a very hacky way of doing this, but when using .resolve() /* this is a very hacky way of doing this, but when using .resolve()
the guildData object gets saved back to the database straight away, the guildData object gets saved back to the database straight away,
meaning it'd be deleted and instnantly re-created. Using .reject 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. */ means that .save doesn't get called by the parent. Very hacky but works. */
guildData
.delete() Util.ask(client, message.channel, message.member, "Are you sure you want to delete all the data for this server? (yes/no)")
.then(() => reject("Data for this server successfully deleted")); .then(response => {
// .then(() => resolve("Data for this server successfully deleted")) if (response.toLowerCase() === "yes")
// .catch(() => reject("Error deleting data for this server")); 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"));
}); });
} }

31
core/commands/stats.js Normal file
View File

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

View File

@ -1,4 +1,5 @@
const Command = require("../command.js"); const Command = require("../command.js");
// @ts-ignore
const ParentPackageJson = require("../../package.json"); const ParentPackageJson = require("../../package.json");
module.exports = new Command({ module.exports = new Command({
@ -10,5 +11,5 @@ module.exports = new Command({
}); });
function invoke() { function invoke() {
return Promise.resolve(ParentPackageJson.version); return Promise.resolve(`${(ParentPackageJson.name + "").replace("discord-bot-", "")} v${ParentPackageJson.version}`);
} }

View File

@ -1,9 +1,14 @@
{ {
"name": "core", "name": "discord-bot-core",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@types/node": {
"version": "8.9.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.9.1.tgz",
"integrity": "sha512-4JFGIC1RSoFngVsT5EZcL793/uRi/OJ3ilsp9DQUr4LZOaMhNM1pPrt9TqlXOnXj3h73hl6NF31v87eQAPXYTg=="
},
"acorn": { "acorn": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz",

View File

@ -2,6 +2,7 @@
"version": "1.0.0", "version": "1.0.0",
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"@types/node": "8.9.1",
"camo": "git+https://github.com/benji7425/camo.git#v0.12.4", "camo": "git+https://github.com/benji7425/camo.git#v0.12.4",
"cron": "1.3.0", "cron": "1.3.0",
"discord.js": "11.2.0", "discord.js": "11.2.0",
@ -10,16 +11,16 @@
"require-all": "2.2.0", "require-all": "2.2.0",
"simple-file-writer": "2.0.0" "simple-file-writer": "2.0.0"
}, },
"name": "core", "name": "discord-bot-core",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/benji7425/core.git" "url": "git+https://github.com/benji7425/discord-bot-core.git"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"bugs": { "bugs": {
"url": "https://github.com/benji7425/core/issues" "url": "https://github.com/benji7425/discord-bot-core/issues"
}, },
"homepage": "https://github.com/benji7425/core#readme", "homepage": "https://github.com/benji7425/discord-bot-core#readme",
"description": "Core code shared amongst my Discord bots" "description": "Core code shared amongst my Discord bots"
} }