Browse Source

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
benji7425 3 years ago
parent
commit
e838b60752
6 changed files with 62 additions and 16 deletions
  1. 4
      core/.gitrepo
  2. 24
      core/commands/reset.js
  3. 31
      core/commands/stats.js
  4. 3
      core/commands/version.js
  5. 7
      core/package-lock.json
  6. 9
      core/package.json

4
core/.gitrepo

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

24
core/commands/reset.js

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

31
core/commands/stats.js

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

3
core/commands/version.js

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

7
core/package-lock.json

@ -1,9 +1,14 @@
{
"name": "core",
"name": "discord-bot-core",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"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": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz",

9
core/package.json

@ -2,6 +2,7 @@
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"@types/node": "8.9.1",
"camo": "git+https://github.com/benji7425/camo.git#v0.12.4",
"cron": "1.3.0",
"discord.js": "11.2.0",
@ -10,16 +11,16 @@
"require-all": "2.2.0",
"simple-file-writer": "2.0.0"
},
"name": "core",
"name": "discord-bot-core",
"repository": {
"type": "git",
"url": "git+https://github.com/benji7425/core.git"
"url": "git+https://github.com/benji7425/discord-bot-core.git"
},
"author": "",
"license": "ISC",
"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"
}
Loading…
Cancel
Save