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 db = require ( "../../utils/database.js" ) ;
const Command = require ( "../../classes/command.js" ) ;
class ChannelCommand extends Command {
async run ( ) {
if ( ! this . message . channel . guild ) return ` ${ this . message . author . mention } , this command only works in servers! ` ;
2021-04-19 14:31:39 +00:00
console . log ( this . message . member . permission ) ;
if ( ! this . message . member . permission . has ( "administrator" ) && this . message . member . id !== process . env . OWNER ) return ` ${ this . message . author . mention } , you need to be an administrator to enable/disable me! ` ;
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
if ( this . args . length === 0 ) return ` ${ this . message . author . mention } , you need to provide whether I should be enabled or disabled in this channel! ` ;
if ( this . args [ 0 ] !== "disable" && this . args [ 0 ] !== "enable" ) return ` ${ this . message . author . mention } , that's not a valid option! ` ;
const guildDB = await db . getGuild ( this . message . channel . guild . id ) ;
if ( this . args [ 0 ] . toLowerCase ( ) === "disable" ) {
let channel ;
if ( this . args [ 1 ] && this . args [ 1 ] . match ( /^<?[@#]?[&!]?\d+>?$/ ) && this . args [ 1 ] >= 21154535154122752 n ) {
const id = this . args [ 1 ] . replaceAll ( "@" , "" ) . replaceAll ( "#" , "" ) . replaceAll ( "!" , "" ) . replaceAll ( "&" , "" ) . replaceAll ( "<" , "" ) . replaceAll ( ">" , "" ) ;
if ( guildDB . disabled . includes ( id ) ) return ` ${ this . message . author . mention } , I'm already disabled in this channel! ` ;
channel = this . message . channel . guild . channels . get ( id ) ;
} else {
if ( guildDB . disabled . includes ( this . message . channel . id ) ) return ` ${ this . message . author . mention } , I'm already disabled in this channel! ` ;
channel = this . message . channel ;
}
await db . disableChannel ( channel ) ;
return ` ${ this . message . author . mention } , I have been disabled in this channel. To re-enable me, just run \` ${ guildDB . prefix } channel enable \` . ` ;
} else if ( this . args [ 0 ] . toLowerCase ( ) === "enable" ) {
let channel ;
if ( this . args [ 1 ] && this . args [ 1 ] . match ( /^<?[@#]?[&!]?\d+>?$/ ) && this . args [ 1 ] >= 21154535154122752 ) {
const id = this . args [ 1 ] . replaceAll ( "@" , "" ) . replaceAll ( "#" , "" ) . replaceAll ( "!" , "" ) . replaceAll ( "&" , "" ) . replaceAll ( "<" , "" ) . replaceAll ( ">" , "" ) ;
if ( ! guildDB . disabled . includes ( id ) ) return ` ${ this . message . author . mention } , I'm not disabled in that channel! ` ;
channel = this . message . channel . guild . channels . get ( id ) ;
} else {
if ( ! guildDB . disabled . includes ( this . message . channel . id ) ) return ` ${ this . message . author . mention } , I'm not disabled in this channel! ` ;
channel = this . message . channel ;
}
await db . enableChannel ( channel ) ;
return ` ${ this . message . author . mention } , I have been re-enabled in this channel. ` ;
}
}
static description = "Enables/disables me in a channel" ;
static arguments = [ "[enable/disable]" , "{id}" ] ;
}
module . exports = ChannelCommand ;