mirror of
https://github.com/danbulant/ssps-bot
synced 2026-06-18 22:01:06 +00:00
37 lines
No EOL
995 B
JavaScript
37 lines
No EOL
995 B
JavaScript
const commando = require("@iceprod/discord.js-commando");
|
|
const { MessageEmbed } = require("discord.js");
|
|
const TurndownService = require('turndown');
|
|
const api = require("../../utils/api");
|
|
|
|
const turndownService = new TurndownService({
|
|
bulletListMarker: "-",
|
|
codeBlockStyle: "fenced"
|
|
});
|
|
|
|
module.exports = class novinky extends commando.Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: "novinky",
|
|
memberName: "novinky",
|
|
group: "ssps",
|
|
description: "Zobrazí novinky ze školy",
|
|
args: []
|
|
});
|
|
}
|
|
|
|
async run(msg) {
|
|
const news = await api.getNews();
|
|
const embed = new MessageEmbed();
|
|
|
|
embed.setTitle("Novinky ze školy");
|
|
|
|
for(const post of news.slice(0, 25)) {
|
|
embed.addField(
|
|
post.title.rendered.trim(),
|
|
turndownService.turndown(post.excerpt.rendered)
|
|
);
|
|
}
|
|
|
|
return msg.reply(embed);
|
|
}
|
|
}; |