Browse Source

git subrepo pull core

subrepo:
  subdir:   "core"
  merged:   "1f14a50"
upstream:
  origin:   "git@github.com:benji7425/discord-bot-core.git"
  branch:   "master"
  commit:   "1f14a50"
git-subrepo:
  version:  "0.3.1"
  origin:   "???"
  commit:   "???"
shorten
benji7425 3 years ago
parent
commit
6a140afbe8
  1. 4
      core/.gitrepo
  2. 10
      core/client.js
  3. 9
      core/commands/reset.js
  4. 5
      core/handle-guild-message.js
  5. 2
      core/package-lock.json

4
core/.gitrepo

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

10
core/client.js

@ -38,8 +38,6 @@ module.exports = class Client extends Discord.Client {
_onReady() {
this.user.setGame(InternalConfig.website.replace(/^https?:\/\//, ""));
CoreUtil.dateLog(`Registered bot ${this.user.username}`);
this.removeDeletedGuilds();
}
_onMessage(message) {
@ -82,12 +80,4 @@ module.exports = class Client extends Discord.Client {
this.login(this._token);
});
}
removeDeletedGuilds() {
this.guildDataModel.find().then(guildDatas => {
for (let guildData of guildDatas)
if (!this.guilds.get(guildData.guildID))
guildData.delete();
});
}
};

9
core/commands/reset.js

@ -10,9 +10,14 @@ module.exports = new Command({
function invoke({ guildData }) {
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(() => resolve("Data for this server successfully deleted"))
.catch(() => reject("Error deleting data for this server"));
.then(() => reject("Data for this server successfully deleted"));
// .then(() => resolve("Data for this server successfully deleted"))
// .catch(() => reject("Error deleting data for this server"));
});
}

5
core/handle-guild-message.js

@ -26,8 +26,9 @@ function handleGuildCommand(client, message, commands, guildData) {
else if (isMemberAdmin || !command.admin)
command.invoke({ message, params, guildData, client, commands, isMemberAdmin })
.then(response => {
guildData.save();
if (response) message.reply(response);
guildData.save()
.then(() => response && message.reply(response))
.catch(() => message.reply("Error saving"));
})
.catch(err => err && message.reply(err));
}

2
core/package-lock.json

@ -1,5 +1,5 @@
{
"name": "discord-bot-core",
"name": "core",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,

Loading…
Cancel
Save