2020-01-05 20:07:57 +00:00
const Command = require ( '../../src/structures/Command' ) ;
module . exports = class Changelog extends Command {
constructor ( ) {
super ( {
name : 'changelog' ,
description : 'View the latest changes of the bot' ,
aliases : [ 'chl' , 'c' ] ,
2020-01-05 22:23:51 +00:00
module : 'Developers' ,
2020-01-05 20:07:57 +00:00
cooldown : 5 ,
guildOnly : false ,
2020-01-05 22:23:51 +00:00
developerOnly : true ,
2020-01-05 20:07:57 +00:00
nsfw : false
} ) ;
}
async command ( ctx ) {
let isDev ;
if ( ctx . vars . developers . find ( ( dev ) => ctx . author . id == dev . id ) ) isDev = true
const ValidActions = /(set|view)/g
let action = ctx . args [ 0 ]
ctx . args . shift ( )
if ( ! action . match ( ValidActions ) ) return ctx . send ( ` You can only ${ isDev ? ctx . utils . format . code ( 'view/set' ) : ctx . utils . format . code ( 'view' ) } a Changelog ` )
// ctx.db.backend.get()
let Changelog = ctx . args . join ( ' ' ) . split ( '|' )
let version = Changelog [ 0 ] . replace ( /\./g , '_' )
let text = Changelog [ 1 ]
// console.log(action, version, text)
if ( action === 'set' ) {
if ( ! isDev ) return ;
await ctx . db . backend . set ( version . trim ( ) , text )
ctx . send ( 'Changelog set, posting...' )
ctx . client . channels . find ( c => c . id == '572515873156235307' ) . send ( ` **__Version ${ version . replace ( /\_/g , '.' ) } __** \n \n ${ text . trim ( ) } ` )
return ctx . send ( 'Sent.' )
} else if ( action === 'view' ) {
let Change = ctx . db . backend . get ( version )
if ( Change === null ) return ctx . send ( ` That is not a valid Version (or it's not in my Database). \n My latest version is ${ ctx . utils . format . bold ( ctx . vars . version ) } . ` )
ctx . send ( ` **__Version ${ version . replace ( /\_/g , '.' ) } __** \n \n ${ Change } ` )
}
}
2020-01-05 22:23:51 +00:00
}