Add rss element content into posted message
This commit is contained in:
parent
3877aa5c59
commit
c1be0ff0e6
|
@ -85,13 +85,24 @@ module.exports = class FeedData {
|
||||||
const channel = guild.channels.get(this.channelID),
|
const channel = guild.channels.get(this.channelID),
|
||||||
role = guild.roles.get(this.roleID);
|
role = guild.roles.get(this.roleID);
|
||||||
|
|
||||||
channel.send((role ? role + " " : "") + latest)
|
channel.send((role || "") + formatPost(articles[0]))
|
||||||
.catch(err => DiscordUtil.dateError(`Error posting in ${channel.id}: ${err.message || err}`));
|
.catch(err => DiscordUtil.dateError(`Error posting in ${channel.id}: ${err.message || err}`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function formatPost(article) {
|
||||||
|
let message = "";
|
||||||
|
if (article.title)
|
||||||
|
message += `\n**${article.title}**`;
|
||||||
|
if (article.content)
|
||||||
|
message += `\n${article.content}`;
|
||||||
|
if (article.link)
|
||||||
|
message += `\n\n${normaliseUrl(article.link)}`;
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
function normaliseUrl(url) {
|
function normaliseUrl(url) {
|
||||||
url = url.replace("https://", "http://"); //hacky way to treat http and https the same
|
url = url.replace("https://", "http://"); //hacky way to treat http and https the same
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// @ts-ignore
|
|
||||||
const Discord = require("discord.js");
|
const Discord = require("discord.js");
|
||||||
|
// @ts-ignore
|
||||||
const ParentPackageJSON = require("../package.json");
|
const ParentPackageJSON = require("../package.json");
|
||||||
|
// @ts-ignore
|
||||||
const InternalConfig = require("./internal-config.json");
|
const InternalConfig = require("./internal-config.json");
|
||||||
|
|
||||||
/**@param param*/
|
/**@param param*/
|
||||||
|
|
Loading…
Reference in a new issue