Skip to content

Commit

Permalink
feat(version): version all print all release notes
Browse files Browse the repository at this point in the history
Parses full the release notes from the change log to do this.
  • Loading branch information
8Mobius8 committed Oct 8, 2020
1 parent 61c147f commit 9eb65b9
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions commands/version.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
const { version } = require('../package.json')
const { releases } = require('./versions.json')
const releases = require('./versions.json')
const { MessageEmbed } = require('discord.js')

module.exports = {
name: 'version',
description: 'Prints version info for the bot.',
cooldown: 5,
execute (message, args) {
const theRelease = releases.find(release => release.version === version)
const theSections = theRelease.sections.map((i, s) => {
return { name: s.name, value: s.notes }
})

const avatarEmbed = new MessageEmbed()
.setTitle(`${version}`)
.setThumbnail(message.client.user.displayAvatarURL({ dynamic: true, size: 128 }))
.setURL(theRelease.url)
.addFields(theSections)

const toshow = []

if (args.indexOf('all') > -1) {
avatarEmbed.setTitle('Release Notes')
toshow.push(...releases)

avatarEmbed.description = ''
for (const release of toshow) {
avatarEmbed.description += `[${release.version}](${release.url}) | `
let notes = ''
for (const section of release.sections) {
notes += `**${section.name}**\n${section.notes}\n\n`
}
avatarEmbed.addField(`${release.version}`, notes)
}
avatarEmbed.description = avatarEmbed.description.substr(0, avatarEmbed.description.length - 3)
} else {
toshow.push(releases.find(release => release.version === version))
avatarEmbed
.setTitle(`${version}`)
.setURL(toshow[0].url)

for (const release of toshow) {
for (const section of release.sections) {
avatarEmbed.addField(section.name, section.notes)
}
}
}

message.channel.send(avatarEmbed)
}
}

0 comments on commit 9eb65b9

Please sign in to comment.