import * as semver from 'semver' ; import * as Package from '../../../package.json' ; import { BotDeveloper , ClientManager } from '../../managers/client.manager' ; import { Command , CommandoClient , CommandoMessage } from 'discord.js-commando' ; import { Message , MessageEmbed , User } from 'discord.js' ; import { Octokit } from '@octokit/rest' ; module . exports = class AboutCommand extends Command { constructor ( client ) { super ( client , { name : 'about' , group : 'general' , memberName : 'about' , description : 'Get all information about the bot.' , examples : [ 'about' ] , clientPermissions : [ 'EMBED_LINKS' ] , throttling : { usages : 1 , duration : 60 , } , } ) ; } async run ( message ) { const owners = this . client . owners . map ( ( owner ) => `${ owner . username }#${ owner . discriminator }` ) . join ( '\n' ) ; const developedBy = ClientManager . get ( ) . getDevelopers ( ) . map ( ( developer ) => `[${ developer . name }](${ developer . link })` ) . join ( '\n' ) ; const embed = new MessageEmbed ( ) . setAuthor ( 'TruckersMP' , 'https://truckersmp.com/assets/img/avatar.png' ) . setTitle ( 'Botranktir' ) . setURL ( 'https://github.com/TruckersMP/botranktir' ) . setColor ( global . BOT_COLOR ) . setFooter ( 'Open source bot for reaction roles' ) . addField ( 'Version' , this . getCurrentVersion ( ) , true ) . addField ( 'Developed by' , developedBy , true ) . addField ( 'Bot\'s Owner' , owners ) ; const latestVersion = await this . getLatestVersion ( ) ; if ( semver . gt ( latestVersion , this . getCurrentVersion ( ) ) ) { embed . addField ( 'Newer Version Available' , latestVersion ) ; } return message . say ( embed ) ; } /**
     * Get the current version of the bot from the package file.
     */ protected getCurrentVersion ( ) { return Package . version . replace ( 'v' , '' ) ; } /**
     * Get the latest version of the bot from Github.
     */ protected async getLatestVersion ( ) { const octokit = new Octokit ( ) ; return octokit . repos . getLatestRelease ( { owner : 'TruckersMP' , repo : 'botranktir' , } ) . then ( ( release ) => release . data . name . replace ( 'v' , '' ) ) . catch ( ( ) => this . getCurrentVersion ( ) ) ; } } ;