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-09-24 17:25:19 +00:00
|
|
|
const self = this.client.users.get(this.author.id) ?? await this.client.rest.users.get(this.author.id);
|
|
|
|
if (this.type === "classic" && this.message.mentions.users[0]) {
|
|
|
|
return this.message.mentions.users[0].avatarURL(null, 512);
|
|
|
|
} else if (member && member > 21154535154122752n) {
|
|
|
|
const user = this.client.users.get(member) ?? await this.client.rest.users.get(member);
|
2022-09-21 05:05:03 +00:00
|
|
|
if (user) {
|
2022-09-24 17:25:19 +00:00
|
|
|
return user.avatarURL(null, 512);
|
|
|
|
} else if (mentionRegex.test(member)) {
|
2022-09-21 05:05:03 +00:00
|
|
|
const id = member.match(mentionRegex)[1];
|
|
|
|
if (id < 21154535154122752n) {
|
|
|
|
this.success = false;
|
|
|
|
return "That's not a valid mention!";
|
|
|
|
}
|
|
|
|
try {
|
2022-09-24 17:25:19 +00:00
|
|
|
const user = this.client.users.get(id) ?? await this.client.rest.users.get(id);
|
|
|
|
return user.avatarURL(null, 512);
|
2022-09-21 05:05:03 +00:00
|
|
|
} catch {
|
2022-09-24 17:25:19 +00:00
|
|
|
return self.avatarURL(null, 512);
|
2022-09-21 05:05:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-09-24 17:25:19 +00:00
|
|
|
return self.avatarURL(null, 512);
|
2021-12-13 23:09:05 +00:00
|
|
|
}
|
2022-09-24 03:25:16 +00:00
|
|
|
} else if (this.args.join(" ") !== "" && this.guild) {
|
2022-09-24 17:25:19 +00:00
|
|
|
const searched = await this.guild.searchMembers({
|
|
|
|
query: this.args.join(" "),
|
|
|
|
limit: 1
|
|
|
|
});
|
|
|
|
if (searched.length === 0) return self.avatarURL(null, 512);
|
|
|
|
const user = this.client.users.get(searched[0].user.id) ?? await this.client.rest.users.get(searched[0].user.id);
|
|
|
|
return user ? user.avatarURL(null, 512) : self.avatarURL(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-09-24 17:25:19 +00:00
|
|
|
return self.avatarURL(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,
|
2022-09-24 17:25:19 +00:00
|
|
|
description: "The member to get the avatar from",
|
2022-06-07 23:26:50 +00:00
|
|
|
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;
|