Fix some issues with 3.2 upgrades
This commit is contained in:
benji7425 2017-12-08 22:54:40 +00:00
parent 71f0e344e1
commit 446df2f8a7
5 changed files with 17 additions and 7 deletions

View File

@ -1,4 +1,6 @@
# Changelog
### Fixed
- Fixed upgrader script not including channel ID in new database
## v3.2.0-b1
### Updated

View File

@ -16,6 +16,7 @@ module.exports = function () {
feedID: feed.id,
url: feed.url,
roleID: feed.roleID,
channelID: feed.channelID,
cachedLinks: feed.cachedLinks,
maxCacheSize: feed.maxCacheSize
}));
@ -24,5 +25,5 @@ module.exports = function () {
guildData.save();
}
FileSystem.unlinkSync("./guilds.json");
FileSystem.rename("./guilds.json", "./guilds.json.backup");
};

View File

@ -64,21 +64,25 @@ module.exports = class FeedData extends Camo.EmbeddedDocument {
}
_doFetchRSS(guild) {
FeedReadPromise(this.url + "asdf")
const that = this;
FeedReadPromise(this.url)
.then(articles => {
if (articles.length > 0 && articles[0].link) {
const latest = normaliseUrl(articles[0].link);
if (!this.cachedLinks.includes(latest)) {
const channel = guild.channels.get(this.channelID),
role = guild.roles.get(this.roleID);
if (!that.cachedLinks.includes(latest)) {
that.cache(latest);
const channel = guild.channels.get(that.channelID),
role = guild.roles.get(that.roleID);
channel.send((role || "") + formatPost(articles[0]))
.catch(err => DiscordUtil.dateDebugError(`Error posting in ${channel.id}: ${err.message || err}`));
}
}
})
.catch(err => DiscordUtil.dateDebugError(`Error reading feed ${this.url}`, err));
.catch(err =>
DiscordUtil.dateDebugError(`Error reading feed ${that.url}`, err));
}
};

View File

@ -17,6 +17,9 @@ function handleGuildMessage(client, message, commands) {
function handleGuildCommand(client, message, commands, guildData) {
const { botName, isMemberAdmin, params, command } = parseDetails(message, commands);
if (!command)
return;
if (params.length < command.expectedParamCount)
message.reply(`Incorrect syntax!\n**Expected:** *${botName} ${command.syntax}*\n**Need help?** *${botName} help*`);

View File

@ -1,5 +1,5 @@
{
"version": "3.2.0-b1",
"version": "3.2.0-b2",
"main": "app/index.js",
"scripts": {
"postinstall": "cd ./discord-bot-core && npm install",