2021-08-19 14:19:14 +00:00
import Command from "../../classes/command.js" ;
2022-06-07 23:26:50 +00:00
const mentionRegex = /^<?[@#]?[&!]?(\d+)>?$/ ;
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
class AvatarCommand extends Command {
async run ( ) {
2022-06-25 03:03:34 +00:00
const member = this . options . member ? ? this . args [ 0 ] ;
2022-06-07 23:26:50 +00:00
const self = await this . client . getRESTUser ( this . author . id ) ;
if ( this . type === "classic" && this . message . mentions [ 0 ] ) {
return this . message . mentions [ 0 ] . dynamicAvatarURL ( null , 512 ) ;
} else if ( await this . ipc . fetchUser ( member ) ) {
const user = await this . ipc . fetchUser ( member ) ;
return user . avatar ? this . client . _formatImage ( ` /avatars/ ${ user . id } / ${ user . avatar } ` , null , 512 ) : ` https://cdn.discordapp.com/embed/avatars/ ${ user . discriminator % 5 } .png ` ; // hacky "solution"
} else if ( mentionRegex . test ( member ) ) {
const id = member . match ( mentionRegex ) [ 1 ] ;
if ( id < 21154535154122752 n ) return "That's not a valid mention!" ;
2021-12-13 23:09:05 +00:00
try {
2022-06-07 23:26:50 +00:00
const user = await this . client . getRESTUser ( id ) ;
return user . avatar ? this . client . _formatImage ( ` /avatars/ ${ user . id } / ${ user . avatar } ` , null , 512 ) : ` https://cdn.discordapp.com/embed/avatars/ ${ user . discriminator % 5 } .png ` ; // repeat of hacky "solution" from above
2021-12-13 23:09:05 +00:00
} catch {
2022-06-07 23:26:50 +00:00
return self . dynamicAvatarURL ( null , 512 ) ;
2021-12-13 23:09:05 +00:00
}
2022-03-31 05:42:03 +00:00
} else if ( this . args . join ( " " ) !== "" && this . channel . guild ) {
2022-06-07 23:26:50 +00:00
const searched = await this . channel . guild . searchMembers ( this . args . join ( " " ) ) ;
if ( searched . length === 0 ) return self . dynamicAvatarURL ( null , 512 ) ;
const user = await this . client . getRESTUser ( searched [ 0 ] . user . id ) ;
return user ? user . dynamicAvatarURL ( null , 512 ) : self . dynamicAvatarURL ( null , 512 ) ;
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
} else {
2022-06-07 23:26:50 +00:00
return self . dynamicAvatarURL ( null , 512 ) ;
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
}
}
static description = "Gets a user's avatar" ;
static aliases = [ "pfp" , "ava" ] ;
static arguments = [ "{mention/id}" ] ;
2022-06-07 23:26:50 +00:00
static flags = [ {
name : "member" ,
type : 6 ,
description : "The member to get the banner from" ,
required : false
} ] ;
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
}
2021-12-13 23:09:05 +00:00
export default AvatarCommand ;