Class commands, improved sharding, and many other changes (#88)
* Load commands recursively
* Sort commands
* Missed a couple of spots
* missed even more spots apparently
* Ported commands in "fun" category to new class-based format, added babel eslint plugin
* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of
* Missed a spot
* Removed unnecessary abort-controller package, add deprecation warning for mongo database
* Added imagereload, clarified premature end message
* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts
* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner
* Converted music/soundboard commands to class format
* Cleanup unnecessary logs
* awful tag command class port
* I literally somehow just learned that you can leave out the constructor in classes
* Pass client directly to commands/events, cleaned up command handler
* Migrated bot to eris-sharder, fixed some error handling stuff
* Remove unused modules
* Fixed type returning
* Switched back to Eris stable
* Some fixes and cleanup
* might wanna correct this
* Implement image command ratelimiting
* Added Bot token prefix, added imagestats, added running endpoint to API
2021-04-12 16:16:12 +00:00
const database = require ( "../../utils/database.js" ) ;
const collections = require ( "../../utils/collections.js" ) ;
const misc = require ( "../../utils/misc.js" ) ;
const paginator = require ( "../../utils/pagination/pagination.js" ) ;
const help = require ( "../../utils/help.js" ) ;
const tips = [ "You can change the bot's prefix using the prefix command." , "Image commands also work with images previously posted in that channel." , "You can use the tags commands to save things for later use." , "You can visit https://projectlounge.pw/esmBot/help.html for a web version of this command list." , "You can view a command's aliases by putting the command name after the help command (e.g. help image)." , "Parameters wrapped in [] are required, while parameters wrapped in {} are optional." , "esmBot is hosted and paid for completely out-of-pocket by the main developer. If you want to support development, please consider donating! https://patreon.com/TheEssem" ] ;
const Command = require ( "../../classes/command.js" ) ;
class HelpCommand extends Command {
async run ( ) {
2021-08-13 03:28:09 +00:00
const { prefix } = this . message . channel . guild ? await database . getGuild ( this . message . channel . guild . id ) : "N/A" ;
Class commands, improved sharding, and many other changes (#88)
* Load commands recursively
* Sort commands
* Missed a couple of spots
* missed even more spots apparently
* Ported commands in "fun" category to new class-based format, added babel eslint plugin
* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of
* Missed a spot
* Removed unnecessary abort-controller package, add deprecation warning for mongo database
* Added imagereload, clarified premature end message
* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts
* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner
* Converted music/soundboard commands to class format
* Cleanup unnecessary logs
* awful tag command class port
* I literally somehow just learned that you can leave out the constructor in classes
* Pass client directly to commands/events, cleaned up command handler
* Migrated bot to eris-sharder, fixed some error handling stuff
* Remove unused modules
* Fixed type returning
* Switched back to Eris stable
* Some fixes and cleanup
* might wanna correct this
* Implement image command ratelimiting
* Added Bot token prefix, added imagestats, added running endpoint to API
2021-04-12 16:16:12 +00:00
const commands = collections . commands ;
const aliases = collections . aliases ;
if ( this . args . length !== 0 && ( commands . has ( this . args [ 0 ] . toLowerCase ( ) ) || aliases . has ( this . args [ 0 ] . toLowerCase ( ) ) ) ) {
const command = aliases . has ( this . args [ 0 ] . toLowerCase ( ) ) ? collections . aliases . get ( this . args [ 0 ] . toLowerCase ( ) ) : this . args [ 0 ] . toLowerCase ( ) ;
const info = collections . info . get ( command ) ;
2021-08-13 03:28:09 +00:00
const counts = await database . getCounts ( ) ;
Class commands, improved sharding, and many other changes (#88)
* Load commands recursively
* Sort commands
* Missed a couple of spots
* missed even more spots apparently
* Ported commands in "fun" category to new class-based format, added babel eslint plugin
* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of
* Missed a spot
* Removed unnecessary abort-controller package, add deprecation warning for mongo database
* Added imagereload, clarified premature end message
* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts
* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner
* Converted music/soundboard commands to class format
* Cleanup unnecessary logs
* awful tag command class port
* I literally somehow just learned that you can leave out the constructor in classes
* Pass client directly to commands/events, cleaned up command handler
* Migrated bot to eris-sharder, fixed some error handling stuff
* Remove unused modules
* Fixed type returning
* Switched back to Eris stable
* Some fixes and cleanup
* might wanna correct this
* Implement image command ratelimiting
* Added Bot token prefix, added imagestats, added running endpoint to API
2021-04-12 16:16:12 +00:00
const embed = {
"embed" : {
"author" : {
"name" : "esmBot Help" ,
"icon_url" : this . client . user . avatarURL
} ,
"title" : ` ${ this . message . channel . guild ? prefix : "" } ${ command } ` ,
"url" : "https://projectlounge.pw/esmBot/help.html" ,
"description" : command === "tags" ? "The main tags command. Check the help page for more info: https://projectlounge.pw/esmBot/help.html" : info . description ,
"color" : 16711680 ,
"fields" : [ {
"name" : "Aliases" ,
2021-04-30 00:03:03 +00:00
"value" : info . aliases . length !== 0 ? info . aliases . join ( ", " ) : "None"
Class commands, improved sharding, and many other changes (#88)
* Load commands recursively
* Sort commands
* Missed a couple of spots
* missed even more spots apparently
* Ported commands in "fun" category to new class-based format, added babel eslint plugin
* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of
* Missed a spot
* Removed unnecessary abort-controller package, add deprecation warning for mongo database
* Added imagereload, clarified premature end message
* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts
* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner
* Converted music/soundboard commands to class format
* Cleanup unnecessary logs
* awful tag command class port
* I literally somehow just learned that you can leave out the constructor in classes
* Pass client directly to commands/events, cleaned up command handler
* Migrated bot to eris-sharder, fixed some error handling stuff
* Remove unused modules
* Fixed type returning
* Switched back to Eris stable
* Some fixes and cleanup
* might wanna correct this
* Implement image command ratelimiting
* Added Bot token prefix, added imagestats, added running endpoint to API
2021-04-12 16:16:12 +00:00
} , {
"name" : "Times Used" ,
"value" : counts [ command ] ,
"inline" : true
} , {
"name" : "Parameters" ,
2021-04-12 21:54:44 +00:00
"value" : command === "tags" ? "[name]" : ( info . params ? ( info . params . length !== 0 ? info . params . join ( " " ) : "None" ) : "None" ) ,
Class commands, improved sharding, and many other changes (#88)
* Load commands recursively
* Sort commands
* Missed a couple of spots
* missed even more spots apparently
* Ported commands in "fun" category to new class-based format, added babel eslint plugin
* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of
* Missed a spot
* Removed unnecessary abort-controller package, add deprecation warning for mongo database
* Added imagereload, clarified premature end message
* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts
* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner
* Converted music/soundboard commands to class format
* Cleanup unnecessary logs
* awful tag command class port
* I literally somehow just learned that you can leave out the constructor in classes
* Pass client directly to commands/events, cleaned up command handler
* Migrated bot to eris-sharder, fixed some error handling stuff
* Remove unused modules
* Fixed type returning
* Switched back to Eris stable
* Some fixes and cleanup
* might wanna correct this
* Implement image command ratelimiting
* Added Bot token prefix, added imagestats, added running endpoint to API
2021-04-12 16:16:12 +00:00
"inline" : true
} ]
}
} ;
2021-07-23 16:13:43 +00:00
if ( info . flags . length !== 0 ) {
const flagInfo = [ ] ;
for ( const flag of info . flags ) {
flagInfo . push ( ` \` -- ${ flag . name } ${ flag . type ? ` =[ ${ flag . type } ] ` : "" } \` - ${ flag . description } ` ) ;
}
embed . embed . fields . push ( {
"name" : "Flags" ,
"value" : flagInfo . join ( "\n" )
} ) ;
}
Class commands, improved sharding, and many other changes (#88)
* Load commands recursively
* Sort commands
* Missed a couple of spots
* missed even more spots apparently
* Ported commands in "fun" category to new class-based format, added babel eslint plugin
* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of
* Missed a spot
* Removed unnecessary abort-controller package, add deprecation warning for mongo database
* Added imagereload, clarified premature end message
* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts
* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner
* Converted music/soundboard commands to class format
* Cleanup unnecessary logs
* awful tag command class port
* I literally somehow just learned that you can leave out the constructor in classes
* Pass client directly to commands/events, cleaned up command handler
* Migrated bot to eris-sharder, fixed some error handling stuff
* Remove unused modules
* Fixed type returning
* Switched back to Eris stable
* Some fixes and cleanup
* might wanna correct this
* Implement image command ratelimiting
* Added Bot token prefix, added imagestats, added running endpoint to API
2021-04-12 16:16:12 +00:00
return embed ;
} else {
2021-07-26 19:43:10 +00:00
if ( this . message . channel . guild && ! this . message . channel . permissionsOf ( this . client . user . id ) . has ( "addReactions" ) ) return "I don't have the `Add Reactions` permission!" ;
if ( this . message . channel . guild && ! this . message . channel . permissionsOf ( this . client . user . id ) . has ( "embedLinks" ) ) return "I don't have the `Embed Links` permission!" ;
Class commands, improved sharding, and many other changes (#88)
* Load commands recursively
* Sort commands
* Missed a couple of spots
* missed even more spots apparently
* Ported commands in "fun" category to new class-based format, added babel eslint plugin
* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of
* Missed a spot
* Removed unnecessary abort-controller package, add deprecation warning for mongo database
* Added imagereload, clarified premature end message
* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts
* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner
* Converted music/soundboard commands to class format
* Cleanup unnecessary logs
* awful tag command class port
* I literally somehow just learned that you can leave out the constructor in classes
* Pass client directly to commands/events, cleaned up command handler
* Migrated bot to eris-sharder, fixed some error handling stuff
* Remove unused modules
* Fixed type returning
* Switched back to Eris stable
* Some fixes and cleanup
* might wanna correct this
* Implement image command ratelimiting
* Added Bot token prefix, added imagestats, added running endpoint to API
2021-04-12 16:16:12 +00:00
const pages = [ ] ;
for ( const category of Object . keys ( help . categories ) ) {
const splitPages = help . categories [ category ] . map ( ( item , index ) => {
return index % 15 === 0 ? help . categories [ category ] . slice ( index , index + 15 ) : null ;
} ) . filter ( ( item ) => {
return item ;
} ) ;
const categoryStringArray = category . split ( "-" ) ;
for ( const index of categoryStringArray . keys ( ) ) {
categoryStringArray [ index ] = categoryStringArray [ index ] . charAt ( 0 ) . toUpperCase ( ) + categoryStringArray [ index ] . slice ( 1 ) ;
}
for ( const page of splitPages ) {
pages . push ( {
title : categoryStringArray . join ( " " ) ,
page : page
} ) ;
}
}
const embeds = [ ] ;
for ( const [ i , value ] of pages . entries ( ) ) {
embeds . push ( {
"embed" : {
"author" : {
"name" : "esmBot Help" ,
"icon_url" : this . client . user . avatarURL
} ,
"title" : value . title ,
"description" : value . page . join ( "\n" ) ,
"color" : 16711680 ,
"footer" : {
"text" : ` Page ${ i + 1 } of ${ pages . length } `
} ,
"fields" : [ {
"name" : "Prefix" ,
"value" : this . message . channel . guild ? prefix : "N/A"
} , {
"name" : "Tip" ,
"value" : misc . random ( tips )
} ]
}
} ) ;
}
return paginator ( this . client , this . message , embeds ) ;
}
}
static description = "Gets a list of commands" ;
static aliases = [ "commands" ] ;
static arguments = [ "{command}" ] ;
}
module . exports = HelpCommand ;